Skip to content

Commit

Permalink
Merge pull request AplaProject#122 from AplaProject/291-full-nodes-ho…
Browse files Browse the repository at this point in the history
…stname

291 Added hostname support in the full_nodes parameter
  • Loading branch information
potehinre committed Jan 23, 2018
2 parents 60780b4 + 6e1a9ee commit 9a5798f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
5 changes: 2 additions & 3 deletions packages/api/smart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,8 @@ func TestUpdateSysParam(t *testing.T) {
{`fuel_rate`, `[["name", "100"]]`},
{`commission_wallet`, `[["1", "0"]]`},
{`commission_wallet`, `[{"1", "50"}]`},
{`full_nodes`, `[["34.12.25", "10", "c1a9e7b2fb8cea2a272e183c3e27e2d59a3ebe613f51873a46885c9201160bd263ef43b583b631edd1284ab42483712fd2ccc40864fe9368115ceeee47a7c7d0"]]`},
{`full_nodes`, `[["1.34.12.25", "100", "c1a9e7b2fb8cea2a272e183c3e27e2d59a3ebe613f51873a46885c9201160bd263ef43b583b631edd1284ab42483712fd2ccc40864fe9368115ceeee47a7"]]`},
{`full_nodes`, `[["34.12.25.100:65d321", "100000000000", "c1a9e7b2fb8cea2a272e183c3e27e2d59a3ebe613f51873a46885c9201160bd263ef43b583b631edd1284ab42483712fd2ccc40864fe9368115ceeee47a7c7d0"]]`},
{`full_nodes`, `[["", "100", "c1a9e7b2fb8cea2a272e183c3e27e2d59a3ebe613f51873a46885c9201160bd263ef43b583b631edd1284ab42483712fd2ccc40864fe9368115ceeee47a7"]]`},
{`full_nodes`, `[["127.0.0.1", "0", "c1a9e7b2fb8cea2a272e183c3e27e2d59a3ebe613f51873a46885c9201160bd263ef43b583b631edd1284ab42483712fd2ccc40864fe9368115ceeee47a7c7d0"]]`},
}
for _, item := range notvalid {
err = postTx(`UpdateSysParam`, &url.Values{`Name`: {item.Name}, `Value`: {item.Value}})
Expand Down
22 changes: 0 additions & 22 deletions packages/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,28 +789,6 @@ func ValidateEmail(email string) bool {
return Re.MatchString(email)
}

// ValidateIPv4 validates IPv4 address and port
func ValidateIPv4(ip string) bool {
ipport := strings.Split(ip, `:`)
addr := strings.Split(ipport[0], `.`)
if len(addr) != 4 || len(ipport) > 2 {
return false
}
for _, val := range addr {
i, err := strconv.Atoi(val)
if err != nil || i < 0 || i > 255 {
return false
}
}
if len(ipport) == 2 {
i, err := strconv.Atoi(ipport[1])
if err != nil || i < 0 || i > 0xffff {
return false
}
}
return true
}

// SliceReverse reverses the slice of int64
func SliceReverse(s []int64) []int64 {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
Expand Down
2 changes: 1 addition & 1 deletion packages/smart/smart_p.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func UpdateSysParam(sc *SmartContract, name, value, conditions string) (int64, e
break check
}
key := converter.StrToInt64(item[1])
if key == 0 || len(item[2]) != 128 || !converter.ValidateIPv4(item[0]) {
if key == 0 || len(item[2]) != 128 || len(item[0]) == 0 {
break check
}
}
Expand Down

0 comments on commit 9a5798f

Please sign in to comment.