Skip to content

Commit 124c549

Browse files
akrem-chabchoubv1rtl
authored andcommitted
fix(node): allow hostnames in public address validation (ethersphere#5312)
1 parent 803e86d commit 124c549

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ require (
4747
go.uber.org/atomic v1.11.0
4848
go.uber.org/goleak v1.3.0
4949
golang.org/x/crypto v0.45.0
50+
golang.org/x/net v0.47.0
5051
golang.org/x/sync v0.18.0
5152
golang.org/x/sys v0.38.0
5253
golang.org/x/term v0.37.0
@@ -169,7 +170,6 @@ require (
169170
go.uber.org/zap v1.27.0 // indirect
170171
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
171172
golang.org/x/mod v0.29.0 // indirect
172-
golang.org/x/net v0.47.0 // indirect
173173
golang.org/x/text v0.31.0 // indirect
174174
golang.org/x/tools v0.38.0 // indirect
175175
google.golang.org/protobuf v1.36.1 // indirect

pkg/node/node_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,28 @@ func TestValidatePublicAddress(t *testing.T) {
6969
expErr: false,
7070
},
7171
{
72-
name: "invalid IP",
73-
addr: "not-an-ip:8080",
74-
expErr: true,
72+
name: "valid hostname",
73+
addr: "example.com:8080",
74+
expErr: false,
75+
},
76+
{
77+
name: "valid hostname with hyphen",
78+
addr: "test-example.com:8080",
79+
expErr: false,
7580
},
7681
{
7782
name: "private IP",
7883
addr: "192.168.1.1:8080",
7984
expErr: true,
8085
},
8186
{
82-
name: "hostname",
83-
addr: "example.com:8080",
87+
name: "invalid hostname format",
88+
addr: "invalid..hostname:8080",
89+
expErr: true,
90+
},
91+
{
92+
name: "hostname starts with hyphen",
93+
addr: "-test.com:8080",
8494
expErr: true,
8595
},
8696
}

0 commit comments

Comments
 (0)