mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
cmd/ensdns: Initial implementation of an ENS<->DNS gateway
This commit is contained in:
parent
ee445a2ba4
commit
495a147c12
5 changed files with 775 additions and 0 deletions
321
cmd/ensdns/contract/ens.go
Normal file
321
cmd/ensdns/contract/ens.go
Normal file
|
|
@ -0,0 +1,321 @@
|
||||||
|
// This file is an automatically generated Go binding. Do not modify as any
|
||||||
|
// change will likely be lost upon the next re-generation!
|
||||||
|
|
||||||
|
package contract
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ENSABI is the input ABI used to generate the binding from.
|
||||||
|
const ENSABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"resolver\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"label\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setSubnodeOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"ttl\",\"type\":\"uint64\"}],\"name\":\"setTTL\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"ttl\",\"outputs\":[{\"name\":\"\",\"type\":\"uint64\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"setResolver\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"label\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"NewOwner\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"resolver\",\"type\":\"address\"}],\"name\":\"NewResolver\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"node\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"ttl\",\"type\":\"uint64\"}],\"name\":\"NewTTL\",\"type\":\"event\"}]"
|
||||||
|
|
||||||
|
// ENSBin is the compiled bytecode used for deploying new contracts.
|
||||||
|
const ENSBin = `0x`
|
||||||
|
|
||||||
|
// DeployENS deploys a new Ethereum contract, binding an instance of ENS to it.
|
||||||
|
func DeployENS(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ENS, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(ENSABI))
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ENSBin), backend)
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
return address, tx, &ENS{ENSCaller: ENSCaller{contract: contract}, ENSTransactor: ENSTransactor{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENS is an auto generated Go binding around an Ethereum contract.
|
||||||
|
type ENS struct {
|
||||||
|
ENSCaller // Read-only binding to the contract
|
||||||
|
ENSTransactor // Write-only binding to the contract
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||||
|
type ENSCaller struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||||
|
type ENSTransactor struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSSession is an auto generated Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call and transact options.
|
||||||
|
type ENSSession struct {
|
||||||
|
Contract *ENS // Generic contract binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call options.
|
||||||
|
type ENSCallerSession struct {
|
||||||
|
Contract *ENSCaller // Generic contract caller binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set transact options.
|
||||||
|
type ENSTransactorSession struct {
|
||||||
|
Contract *ENSTransactor // Generic contract transactor binding to set the session for
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||||
|
type ENSRaw struct {
|
||||||
|
Contract *ENS // Generic contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||||
|
type ENSCallerRaw struct {
|
||||||
|
Contract *ENSCaller // Generic read-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// ENSTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||||
|
type ENSTransactorRaw struct {
|
||||||
|
Contract *ENSTransactor // Generic write-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewENS creates a new instance of ENS, bound to a specific deployed contract.
|
||||||
|
func NewENS(address common.Address, backend bind.ContractBackend) (*ENS, error) {
|
||||||
|
contract, err := bindENS(address, backend, backend)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ENS{ENSCaller: ENSCaller{contract: contract}, ENSTransactor: ENSTransactor{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewENSCaller creates a new read-only instance of ENS, bound to a specific deployed contract.
|
||||||
|
func NewENSCaller(address common.Address, caller bind.ContractCaller) (*ENSCaller, error) {
|
||||||
|
contract, err := bindENS(address, caller, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ENSCaller{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewENSTransactor creates a new write-only instance of ENS, bound to a specific deployed contract.
|
||||||
|
func NewENSTransactor(address common.Address, transactor bind.ContractTransactor) (*ENSTransactor, error) {
|
||||||
|
contract, err := bindENS(address, nil, transactor)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ENSTransactor{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindENS binds a generic wrapper to an already deployed contract.
|
||||||
|
func bindENS(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(ENSABI))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bind.NewBoundContract(address, parsed, caller, transactor), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call invokes the (constant) contract method with params as input values and
|
||||||
|
// sets the output to result. The result type might be a single field for simple
|
||||||
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
|
// returns.
|
||||||
|
func (_ENS *ENSRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||||
|
return _ENS.Contract.ENSCaller.contract.Call(opts, result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||||
|
// its default method if one is available.
|
||||||
|
func (_ENS *ENSRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.ENSTransactor.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_ENS *ENSRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.ENSTransactor.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call invokes the (constant) contract method with params as input values and
|
||||||
|
// sets the output to result. The result type might be a single field for simple
|
||||||
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
|
// returns.
|
||||||
|
func (_ENS *ENSCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||||
|
return _ENS.Contract.contract.Call(opts, result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||||
|
// its default method if one is available.
|
||||||
|
func (_ENS *ENSTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_ENS *ENSTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Owner is a free data retrieval call binding the contract method 0x02571be3.
|
||||||
|
//
|
||||||
|
// Solidity: function owner(node bytes32) constant returns(address)
|
||||||
|
func (_ENS *ENSCaller) Owner(opts *bind.CallOpts, node [32]byte) (common.Address, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new(common.Address)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _ENS.contract.Call(opts, out, "owner", node)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Owner is a free data retrieval call binding the contract method 0x02571be3.
|
||||||
|
//
|
||||||
|
// Solidity: function owner(node bytes32) constant returns(address)
|
||||||
|
func (_ENS *ENSSession) Owner(node [32]byte) (common.Address, error) {
|
||||||
|
return _ENS.Contract.Owner(&_ENS.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Owner is a free data retrieval call binding the contract method 0x02571be3.
|
||||||
|
//
|
||||||
|
// Solidity: function owner(node bytes32) constant returns(address)
|
||||||
|
func (_ENS *ENSCallerSession) Owner(node [32]byte) (common.Address, error) {
|
||||||
|
return _ENS.Contract.Owner(&_ENS.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolver is a free data retrieval call binding the contract method 0x0178b8bf.
|
||||||
|
//
|
||||||
|
// Solidity: function resolver(node bytes32) constant returns(address)
|
||||||
|
func (_ENS *ENSCaller) Resolver(opts *bind.CallOpts, node [32]byte) (common.Address, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new(common.Address)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _ENS.contract.Call(opts, out, "resolver", node)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolver is a free data retrieval call binding the contract method 0x0178b8bf.
|
||||||
|
//
|
||||||
|
// Solidity: function resolver(node bytes32) constant returns(address)
|
||||||
|
func (_ENS *ENSSession) Resolver(node [32]byte) (common.Address, error) {
|
||||||
|
return _ENS.Contract.Resolver(&_ENS.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolver is a free data retrieval call binding the contract method 0x0178b8bf.
|
||||||
|
//
|
||||||
|
// Solidity: function resolver(node bytes32) constant returns(address)
|
||||||
|
func (_ENS *ENSCallerSession) Resolver(node [32]byte) (common.Address, error) {
|
||||||
|
return _ENS.Contract.Resolver(&_ENS.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ttl is a free data retrieval call binding the contract method 0x16a25cbd.
|
||||||
|
//
|
||||||
|
// Solidity: function ttl(node bytes32) constant returns(uint64)
|
||||||
|
func (_ENS *ENSCaller) Ttl(opts *bind.CallOpts, node [32]byte) (uint64, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new(uint64)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _ENS.contract.Call(opts, out, "ttl", node)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ttl is a free data retrieval call binding the contract method 0x16a25cbd.
|
||||||
|
//
|
||||||
|
// Solidity: function ttl(node bytes32) constant returns(uint64)
|
||||||
|
func (_ENS *ENSSession) Ttl(node [32]byte) (uint64, error) {
|
||||||
|
return _ENS.Contract.Ttl(&_ENS.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ttl is a free data retrieval call binding the contract method 0x16a25cbd.
|
||||||
|
//
|
||||||
|
// Solidity: function ttl(node bytes32) constant returns(uint64)
|
||||||
|
func (_ENS *ENSCallerSession) Ttl(node [32]byte) (uint64, error) {
|
||||||
|
return _ENS.Contract.Ttl(&_ENS.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||||
|
//
|
||||||
|
// Solidity: function setOwner(node bytes32, owner address) returns()
|
||||||
|
func (_ENS *ENSTransactor) SetOwner(opts *bind.TransactOpts, node [32]byte, owner common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.contract.Transact(opts, "setOwner", node, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||||
|
//
|
||||||
|
// Solidity: function setOwner(node bytes32, owner address) returns()
|
||||||
|
func (_ENS *ENSSession) SetOwner(node [32]byte, owner common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetOwner(&_ENS.TransactOpts, node, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOwner is a paid mutator transaction binding the contract method 0x5b0fc9c3.
|
||||||
|
//
|
||||||
|
// Solidity: function setOwner(node bytes32, owner address) returns()
|
||||||
|
func (_ENS *ENSTransactorSession) SetOwner(node [32]byte, owner common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetOwner(&_ENS.TransactOpts, node, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResolver is a paid mutator transaction binding the contract method 0x1896f70a.
|
||||||
|
//
|
||||||
|
// Solidity: function setResolver(node bytes32, resolver address) returns()
|
||||||
|
func (_ENS *ENSTransactor) SetResolver(opts *bind.TransactOpts, node [32]byte, resolver common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.contract.Transact(opts, "setResolver", node, resolver)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResolver is a paid mutator transaction binding the contract method 0x1896f70a.
|
||||||
|
//
|
||||||
|
// Solidity: function setResolver(node bytes32, resolver address) returns()
|
||||||
|
func (_ENS *ENSSession) SetResolver(node [32]byte, resolver common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetResolver(&_ENS.TransactOpts, node, resolver)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResolver is a paid mutator transaction binding the contract method 0x1896f70a.
|
||||||
|
//
|
||||||
|
// Solidity: function setResolver(node bytes32, resolver address) returns()
|
||||||
|
func (_ENS *ENSTransactorSession) SetResolver(node [32]byte, resolver common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetResolver(&_ENS.TransactOpts, node, resolver)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubnodeOwner is a paid mutator transaction binding the contract method 0x06ab5923.
|
||||||
|
//
|
||||||
|
// Solidity: function setSubnodeOwner(node bytes32, label bytes32, owner address) returns()
|
||||||
|
func (_ENS *ENSTransactor) SetSubnodeOwner(opts *bind.TransactOpts, node [32]byte, label [32]byte, owner common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.contract.Transact(opts, "setSubnodeOwner", node, label, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubnodeOwner is a paid mutator transaction binding the contract method 0x06ab5923.
|
||||||
|
//
|
||||||
|
// Solidity: function setSubnodeOwner(node bytes32, label bytes32, owner address) returns()
|
||||||
|
func (_ENS *ENSSession) SetSubnodeOwner(node [32]byte, label [32]byte, owner common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetSubnodeOwner(&_ENS.TransactOpts, node, label, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSubnodeOwner is a paid mutator transaction binding the contract method 0x06ab5923.
|
||||||
|
//
|
||||||
|
// Solidity: function setSubnodeOwner(node bytes32, label bytes32, owner address) returns()
|
||||||
|
func (_ENS *ENSTransactorSession) SetSubnodeOwner(node [32]byte, label [32]byte, owner common.Address) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetSubnodeOwner(&_ENS.TransactOpts, node, label, owner)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTTL is a paid mutator transaction binding the contract method 0x14ab9038.
|
||||||
|
//
|
||||||
|
// Solidity: function setTTL(node bytes32, ttl uint64) returns()
|
||||||
|
func (_ENS *ENSTransactor) SetTTL(opts *bind.TransactOpts, node [32]byte, ttl uint64) (*types.Transaction, error) {
|
||||||
|
return _ENS.contract.Transact(opts, "setTTL", node, ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTTL is a paid mutator transaction binding the contract method 0x14ab9038.
|
||||||
|
//
|
||||||
|
// Solidity: function setTTL(node bytes32, ttl uint64) returns()
|
||||||
|
func (_ENS *ENSSession) SetTTL(node [32]byte, ttl uint64) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetTTL(&_ENS.TransactOpts, node, ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTTL is a paid mutator transaction binding the contract method 0x14ab9038.
|
||||||
|
//
|
||||||
|
// Solidity: function setTTL(node bytes32, ttl uint64) returns()
|
||||||
|
func (_ENS *ENSTransactorSession) SetTTL(node [32]byte, ttl uint64) (*types.Transaction, error) {
|
||||||
|
return _ENS.Contract.SetTTL(&_ENS.TransactOpts, node, ttl)
|
||||||
|
}
|
||||||
16
cmd/ensdns/contract/ens.sol
Normal file
16
cmd/ensdns/contract/ens.sol
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
pragma solidity ^0.4.0;
|
||||||
|
|
||||||
|
contract ENS {
|
||||||
|
function owner(bytes32 node) constant returns(address);
|
||||||
|
function resolver(bytes32 node) constant returns(address);
|
||||||
|
function ttl(bytes32 node) constant returns(uint64);
|
||||||
|
function setOwner(bytes32 node, address owner);
|
||||||
|
function setSubnodeOwner(bytes32 node, bytes32 label, address owner);
|
||||||
|
function setResolver(bytes32 node, address resolver);
|
||||||
|
function setTTL(bytes32 node, uint64 ttl);
|
||||||
|
|
||||||
|
event Transfer(bytes32 indexed node, address owner);
|
||||||
|
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
|
||||||
|
event NewResolver(bytes32 indexed node, address resolver);
|
||||||
|
event NewTTL(bytes32 indexed node, uint64 ttl);
|
||||||
|
}
|
||||||
251
cmd/ensdns/contract/resolver.go
Normal file
251
cmd/ensdns/contract/resolver.go
Normal file
|
|
@ -0,0 +1,251 @@
|
||||||
|
// This file is an automatically generated Go binding. Do not modify as any
|
||||||
|
// change will likely be lost upon the next re-generation!
|
||||||
|
|
||||||
|
package contract
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResolverABI is the input ABI used to generate the binding from.
|
||||||
|
const ResolverABI = "[{\"constant\":true,\"inputs\":[{\"name\":\"interfaceID\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"}],\"name\":\"addr\",\"outputs\":[{\"name\":\"ret\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"node\",\"type\":\"bytes32\"},{\"name\":\"qtype\",\"type\":\"uint16\"},{\"name\":\"qclass\",\"type\":\"uint16\"},{\"name\":\"index\",\"type\":\"uint32\"}],\"name\":\"dnsrr\",\"outputs\":[{\"name\":\"rtype\",\"type\":\"uint16\"},{\"name\":\"rclass\",\"type\":\"uint16\"},{\"name\":\"data\",\"type\":\"bytes\"}],\"payable\":false,\"type\":\"function\"}]"
|
||||||
|
|
||||||
|
// ResolverBin is the compiled bytecode used for deploying new contracts.
|
||||||
|
const ResolverBin = `0x`
|
||||||
|
|
||||||
|
// DeployResolver deploys a new Ethereum contract, binding an instance of Resolver to it.
|
||||||
|
func DeployResolver(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Resolver, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(ResolverABI))
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ResolverBin), backend)
|
||||||
|
if err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
|
}
|
||||||
|
return address, tx, &Resolver{ResolverCaller: ResolverCaller{contract: contract}, ResolverTransactor: ResolverTransactor{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolver is an auto generated Go binding around an Ethereum contract.
|
||||||
|
type Resolver struct {
|
||||||
|
ResolverCaller // Read-only binding to the contract
|
||||||
|
ResolverTransactor // Write-only binding to the contract
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||||
|
type ResolverCaller struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||||
|
type ResolverTransactor struct {
|
||||||
|
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverSession is an auto generated Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call and transact options.
|
||||||
|
type ResolverSession struct {
|
||||||
|
Contract *Resolver // Generic contract binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set call options.
|
||||||
|
type ResolverCallerSession struct {
|
||||||
|
Contract *ResolverCaller // Generic contract caller binding to set the session for
|
||||||
|
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||||
|
// with pre-set transact options.
|
||||||
|
type ResolverTransactorSession struct {
|
||||||
|
Contract *ResolverTransactor // Generic contract transactor binding to set the session for
|
||||||
|
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||||
|
type ResolverRaw struct {
|
||||||
|
Contract *Resolver // Generic contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||||
|
type ResolverCallerRaw struct {
|
||||||
|
Contract *ResolverCaller // Generic read-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolverTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||||
|
type ResolverTransactorRaw struct {
|
||||||
|
Contract *ResolverTransactor // Generic write-only contract binding to access the raw methods on
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResolver creates a new instance of Resolver, bound to a specific deployed contract.
|
||||||
|
func NewResolver(address common.Address, backend bind.ContractBackend) (*Resolver, error) {
|
||||||
|
contract, err := bindResolver(address, backend, backend)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Resolver{ResolverCaller: ResolverCaller{contract: contract}, ResolverTransactor: ResolverTransactor{contract: contract}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResolverCaller creates a new read-only instance of Resolver, bound to a specific deployed contract.
|
||||||
|
func NewResolverCaller(address common.Address, caller bind.ContractCaller) (*ResolverCaller, error) {
|
||||||
|
contract, err := bindResolver(address, caller, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ResolverCaller{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResolverTransactor creates a new write-only instance of Resolver, bound to a specific deployed contract.
|
||||||
|
func NewResolverTransactor(address common.Address, transactor bind.ContractTransactor) (*ResolverTransactor, error) {
|
||||||
|
contract, err := bindResolver(address, nil, transactor)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ResolverTransactor{contract: contract}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindResolver binds a generic wrapper to an already deployed contract.
|
||||||
|
func bindResolver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor) (*bind.BoundContract, error) {
|
||||||
|
parsed, err := abi.JSON(strings.NewReader(ResolverABI))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return bind.NewBoundContract(address, parsed, caller, transactor), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call invokes the (constant) contract method with params as input values and
|
||||||
|
// sets the output to result. The result type might be a single field for simple
|
||||||
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
|
// returns.
|
||||||
|
func (_Resolver *ResolverRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||||
|
return _Resolver.Contract.ResolverCaller.contract.Call(opts, result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||||
|
// its default method if one is available.
|
||||||
|
func (_Resolver *ResolverRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _Resolver.Contract.ResolverTransactor.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_Resolver *ResolverRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _Resolver.Contract.ResolverTransactor.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call invokes the (constant) contract method with params as input values and
|
||||||
|
// sets the output to result. The result type might be a single field for simple
|
||||||
|
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||||
|
// returns.
|
||||||
|
func (_Resolver *ResolverCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
|
||||||
|
return _Resolver.Contract.contract.Call(opts, result, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||||
|
// its default method if one is available.
|
||||||
|
func (_Resolver *ResolverTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return _Resolver.Contract.contract.Transfer(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transact invokes the (paid) contract method with params as input values.
|
||||||
|
func (_Resolver *ResolverTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||||
|
return _Resolver.Contract.contract.Transact(opts, method, params...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Addr is a free data retrieval call binding the contract method 0x3b3b57de.
|
||||||
|
//
|
||||||
|
// Solidity: function addr(node bytes32) constant returns(ret address)
|
||||||
|
func (_Resolver *ResolverCaller) Addr(opts *bind.CallOpts, node [32]byte) (common.Address, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new(common.Address)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _Resolver.contract.Call(opts, out, "addr", node)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Addr is a free data retrieval call binding the contract method 0x3b3b57de.
|
||||||
|
//
|
||||||
|
// Solidity: function addr(node bytes32) constant returns(ret address)
|
||||||
|
func (_Resolver *ResolverSession) Addr(node [32]byte) (common.Address, error) {
|
||||||
|
return _Resolver.Contract.Addr(&_Resolver.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Addr is a free data retrieval call binding the contract method 0x3b3b57de.
|
||||||
|
//
|
||||||
|
// Solidity: function addr(node bytes32) constant returns(ret address)
|
||||||
|
func (_Resolver *ResolverCallerSession) Addr(node [32]byte) (common.Address, error) {
|
||||||
|
return _Resolver.Contract.Addr(&_Resolver.CallOpts, node)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dnsrr is a free data retrieval call binding the contract method 0xfcca1f4e.
|
||||||
|
//
|
||||||
|
// Solidity: function dnsrr(node bytes32, qtype uint16, qclass uint16, index uint32) constant returns(rtype uint16, rclass uint16, data bytes)
|
||||||
|
func (_Resolver *ResolverCaller) Dnsrr(opts *bind.CallOpts, node [32]byte, qtype uint16, qclass uint16, index uint32) (struct {
|
||||||
|
Rtype uint16
|
||||||
|
Rclass uint16
|
||||||
|
Data []byte
|
||||||
|
}, error) {
|
||||||
|
ret := new(struct {
|
||||||
|
Rtype uint16
|
||||||
|
Rclass uint16
|
||||||
|
Data []byte
|
||||||
|
})
|
||||||
|
out := ret
|
||||||
|
err := _Resolver.contract.Call(opts, out, "dnsrr", node, qtype, qclass, index)
|
||||||
|
return *ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dnsrr is a free data retrieval call binding the contract method 0xfcca1f4e.
|
||||||
|
//
|
||||||
|
// Solidity: function dnsrr(node bytes32, qtype uint16, qclass uint16, index uint32) constant returns(rtype uint16, rclass uint16, data bytes)
|
||||||
|
func (_Resolver *ResolverSession) Dnsrr(node [32]byte, qtype uint16, qclass uint16, index uint32) (struct {
|
||||||
|
Rtype uint16
|
||||||
|
Rclass uint16
|
||||||
|
Data []byte
|
||||||
|
}, error) {
|
||||||
|
return _Resolver.Contract.Dnsrr(&_Resolver.CallOpts, node, qtype, qclass, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dnsrr is a free data retrieval call binding the contract method 0xfcca1f4e.
|
||||||
|
//
|
||||||
|
// Solidity: function dnsrr(node bytes32, qtype uint16, qclass uint16, index uint32) constant returns(rtype uint16, rclass uint16, data bytes)
|
||||||
|
func (_Resolver *ResolverCallerSession) Dnsrr(node [32]byte, qtype uint16, qclass uint16, index uint32) (struct {
|
||||||
|
Rtype uint16
|
||||||
|
Rclass uint16
|
||||||
|
Data []byte
|
||||||
|
}, error) {
|
||||||
|
return _Resolver.Contract.Dnsrr(&_Resolver.CallOpts, node, qtype, qclass, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7.
|
||||||
|
//
|
||||||
|
// Solidity: function supportsInterface(interfaceID bytes4) constant returns(bool)
|
||||||
|
func (_Resolver *ResolverCaller) SupportsInterface(opts *bind.CallOpts, interfaceID [4]byte) (bool, error) {
|
||||||
|
var (
|
||||||
|
ret0 = new(bool)
|
||||||
|
)
|
||||||
|
out := ret0
|
||||||
|
err := _Resolver.contract.Call(opts, out, "supportsInterface", interfaceID)
|
||||||
|
return *ret0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7.
|
||||||
|
//
|
||||||
|
// Solidity: function supportsInterface(interfaceID bytes4) constant returns(bool)
|
||||||
|
func (_Resolver *ResolverSession) SupportsInterface(interfaceID [4]byte) (bool, error) {
|
||||||
|
return _Resolver.Contract.SupportsInterface(&_Resolver.CallOpts, interfaceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7.
|
||||||
|
//
|
||||||
|
// Solidity: function supportsInterface(interfaceID bytes4) constant returns(bool)
|
||||||
|
func (_Resolver *ResolverCallerSession) SupportsInterface(interfaceID [4]byte) (bool, error) {
|
||||||
|
return _Resolver.Contract.SupportsInterface(&_Resolver.CallOpts, interfaceID)
|
||||||
|
}
|
||||||
8
cmd/ensdns/contract/resolver.sol
Normal file
8
cmd/ensdns/contract/resolver.sol
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
pragma solidity ^0.4.0;
|
||||||
|
|
||||||
|
contract Resolver {
|
||||||
|
function supportsInterface(bytes4 interfaceID) constant returns (bool);
|
||||||
|
function addr(bytes32 node) constant returns (address ret);
|
||||||
|
function dnsrr(bytes32 node, uint16 qtype, uint16 qclass, uint32 index)
|
||||||
|
constant returns (uint16 rtype, uint16 rclass, bytes data);
|
||||||
|
}
|
||||||
179
cmd/ensdns/main.go
Normal file
179
cmd/ensdns/main.go
Normal file
|
|
@ -0,0 +1,179 @@
|
||||||
|
// Copyright 2016 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
//go:generate abigen --sol contract/ens.sol --pkg contract --out contract/ens.go
|
||||||
|
//go:generate abigen --sol contract/resolver.sol --pkg contract --out contract/resolver.go
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/ensdns/contract"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
"github.com/miekg/dns"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
gethAddressFlag = flag.String("geth", "ws://localhost:8546", "Path to connect to geth on")
|
||||||
|
registryAddressFlag = flag.String("registry", "", "Address of ENS registry")
|
||||||
|
listenAddressFlag = flag.String("address", ":8053", "Address and port to listen on")
|
||||||
|
)
|
||||||
|
|
||||||
|
func nameHash(name string) common.Hash {
|
||||||
|
if name == "" {
|
||||||
|
return common.Hash{}
|
||||||
|
}
|
||||||
|
|
||||||
|
parts := strings.SplitN(name, ".", 2)
|
||||||
|
label := crypto.Keccak256Hash([]byte(parts[0]))
|
||||||
|
parent := common.Hash{}
|
||||||
|
if len(parts) > 1 {
|
||||||
|
parent = nameHash(parts[1])
|
||||||
|
}
|
||||||
|
return crypto.Keccak256Hash(parent[:], label[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
type ENSDNS struct {
|
||||||
|
backend bind.ContractBackend
|
||||||
|
ens *contract.ENSSession
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(backend bind.ContractBackend, registryAddress common.Address) (*ENSDNS, error) {
|
||||||
|
ens, err := contract.NewENS(registryAddress, backend)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ENSDNS{
|
||||||
|
backend: backend,
|
||||||
|
ens: &contract.ENSSession{
|
||||||
|
Contract: ens,
|
||||||
|
TransactOpts: bind.TransactOpts{},
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *ENSDNS) Handle(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
|
m := new(dns.Msg)
|
||||||
|
m.SetReply(r)
|
||||||
|
|
||||||
|
for _, question := range r.Question {
|
||||||
|
answers, err := ed.resolve(question)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error resolving query %v: %v", question, err)
|
||||||
|
m.Rcode = dns.RcodeServerFailure
|
||||||
|
}
|
||||||
|
m.Answer = append(m.Answer, answers...)
|
||||||
|
}
|
||||||
|
w.WriteMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *ENSDNS) getResolver(node common.Hash) (*contract.ResolverSession, error) {
|
||||||
|
resolverAddr, err := ed.ens.Resolver(node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resolver, err := contract.NewResolver(resolverAddr, ed.backend)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &contract.ResolverSession{
|
||||||
|
Contract: resolver,
|
||||||
|
TransactOpts: ed.ens.TransactOpts,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *ENSDNS) resolve(question dns.Question) (records []dns.RR, err error) {
|
||||||
|
log.Printf("Resolving query: %s", question.String())
|
||||||
|
|
||||||
|
node := nameHash(question.Name)
|
||||||
|
|
||||||
|
resolver, err := ed.getResolver(node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ttl, err := ed.ens.Ttl(node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
response, err := resolver.Dnsrr(node, question.Qtype, question.Qclass, uint32(i))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if response.Rtype == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
hexdata := hex.EncodeToString(response.Data)
|
||||||
|
|
||||||
|
records = append(records, &dns.RFC3597{
|
||||||
|
Hdr: dns.RR_Header{
|
||||||
|
Name: question.Name,
|
||||||
|
Rrtype: response.Rtype,
|
||||||
|
Class: response.Rclass,
|
||||||
|
Ttl: uint32(ttl),
|
||||||
|
},
|
||||||
|
Rdata: hexdata,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return records, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func serve(addr string) {
|
||||||
|
server := &dns.Server{Addr: addr, Net: "udp", TsigSecret: nil}
|
||||||
|
if err := server.ListenAndServe(); err != nil {
|
||||||
|
log.Fatalf("DNS server failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
client, err := ethclient.Dial(*gethAddressFlag)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error connecting to geth: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ensdns, err := New(client, common.HexToAddress(*registryAddressFlag))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error constructing ENSDNS: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dns.HandleFunc(".", ensdns.Handle)
|
||||||
|
go serve(*listenAddressFlag)
|
||||||
|
|
||||||
|
log.Printf("Listening on %s", *listenAddressFlag)
|
||||||
|
|
||||||
|
sig := make(chan os.Signal)
|
||||||
|
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
s := <-sig
|
||||||
|
log.Printf("Signal (%s) received, stopping\n", s)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue