Browse Source

Resolve host for NetAddressFromString(). Test fix.

pull/61/head
Jae Kwon 10 years ago
parent
commit
fcc26d7355
6 changed files with 39 additions and 19 deletions
  1. +1
    -1
      binary/reflect.go
  2. +1
    -0
      cmd/barak/main.go
  3. +9
    -6
      cmd/barak/seed0
  4. +9
    -6
      cmd/barak/seed1
  5. +9
    -6
      cmd/barak/seed2
  6. +10
    -0
      p2p/netaddress.go

+ 1
- 1
binary/reflect.go View File

@ -170,7 +170,7 @@ func readReflect(rv reflect.Value, rt reflect.Type, r io.Reader, n *int64, err *
}
crt, ok := typeInfo.ByteToType[typeByte]
if !ok {
*err = errors.New(Fmt("Unexpected type byte %X for type %v", typeByte, crt))
*err = errors.New(Fmt("Unexpected type byte %X for type %v", typeByte, rt))
return
}
crv := reflect.New(crt).Elem()


+ 1
- 0
cmd/barak/main.go View File

@ -86,6 +86,7 @@ func main() {
if err != nil {
panic(Fmt("Error creating barak rootDir: %v", err))
}
barak.registries = options.Registries
// Write pid to file.
err = AtomicWriteFile(barak.rootDir+"/pidfile", []byte(Fmt("%v", barak.pid)))


+ 9
- 6
cmd/barak/seed0 View File

@ -1,9 +1,12 @@
{
"ListenAddress": "0.0.0.0:46660",
"ListenAddress": "0.0.0.0:46660",
"Validators": [
{
"VotingPower": 1,
"PubKey": [1,"3A2C5C341FFC1D5F7AB518519FF8289D3BFAB82DFD6E167B926FAD72C1BF10F8"]
}
]
{
"VotingPower": 1,
"PubKey": [1,"3A2C5C341FFC1D5F7AB518519FF8289D3BFAB82DFD6E167B926FAD72C1BF10F8"]
}
],
"Registries": [
"http://navytoad.chaintest.net:46660"
]
}

+ 9
- 6
cmd/barak/seed1 View File

@ -1,9 +1,12 @@
{
"ListenAddress": "0.0.0.0:46661",
"ListenAddress": "0.0.0.0:46661",
"Validators": [
{
"VotingPower": 1,
"PubKey": [1,"3A2C5C341FFC1D5F7AB518519FF8289D3BFAB82DFD6E167B926FAD72C1BF10F8"]
}
]
{
"VotingPower": 1,
"PubKey": [1,"3A2C5C341FFC1D5F7AB518519FF8289D3BFAB82DFD6E167B926FAD72C1BF10F8"]
}
],
"Registries": [
"http://navytoad.chaintest.net:46660"
]
}

+ 9
- 6
cmd/barak/seed2 View File

@ -1,9 +1,12 @@
{
"ListenAddress": "0.0.0.0:46662",
"ListenAddress": "0.0.0.0:46662",
"Validators": [
{
"VotingPower": 1,
"PubKey": [1,"3A2C5C341FFC1D5F7AB518519FF8289D3BFAB82DFD6E167B926FAD72C1BF10F8"]
}
]
{
"VotingPower": 1,
"PubKey": [1,"3A2C5C341FFC1D5F7AB518519FF8289D3BFAB82DFD6E167B926FAD72C1BF10F8"]
}
],
"Registries": [
"http://navytoad.chaintest.net:46660"
]
}

+ 10
- 0
p2p/netaddress.go View File

@ -28,12 +28,22 @@ func NewNetAddress(addr net.Addr) *NetAddress {
return NewNetAddressIPPort(ip, port)
}
// Also resolves the host if host is not an IP.
func NewNetAddressString(addr string) *NetAddress {
host, portStr, err := net.SplitHostPort(addr)
if err != nil {
panic(err)
}
ip := net.ParseIP(host)
if ip == nil {
if len(host) > 0 {
ips, err := net.LookupIP(host)
if err != nil {
panic(err)
}
ip = ips[0]
}
}
port, err := strconv.ParseUint(portStr, 10, 16)
if err != nil {
panic(err)


Loading…
Cancel
Save