Skip to content

Commit

Permalink
Reworked get-listener to use netip.AddrPort
Browse files Browse the repository at this point in the history
  • Loading branch information
twystd committed May 28, 2024
1 parent 9a76bdc commit c91db9e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/uhppoted/uhppote-simulator
go 1.22

require (
github.com/uhppoted/uhppote-core v0.8.9-0.20240527172601-d5317b598bb8
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240527174018-4ff1fd4a0224
github.com/uhppoted/uhppote-core v0.8.9-0.20240528150603-37c5df8bb47f
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240528151010-a3cffa5b9381
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/uhppoted/uhppote-core v0.8.9-0.20240524165731-f11a293bdd8d h1:3i+zWCi
github.com/uhppoted/uhppote-core v0.8.9-0.20240524165731-f11a293bdd8d/go.mod h1:Q+DHtT8s74efLs2b0eF20DRBUL9yBkySwaTQ+0lsEVM=
github.com/uhppoted/uhppote-core v0.8.9-0.20240527172601-d5317b598bb8 h1:54HfgoJgeDfMDJW2cKF/QDy38dh1qKxv9SMTxVlVOVk=
github.com/uhppoted/uhppote-core v0.8.9-0.20240527172601-d5317b598bb8/go.mod h1:Q+DHtT8s74efLs2b0eF20DRBUL9yBkySwaTQ+0lsEVM=
github.com/uhppoted/uhppote-core v0.8.9-0.20240528150603-37c5df8bb47f h1:cee7NdQFQ8P+C6u1J++FFAaK+yr3aV0hHXlvIK4sXiQ=
github.com/uhppoted/uhppote-core v0.8.9-0.20240528150603-37c5df8bb47f/go.mod h1:Q+DHtT8s74efLs2b0eF20DRBUL9yBkySwaTQ+0lsEVM=
github.com/uhppoted/uhppoted-lib v0.8.5 h1:X5RarX5QMRGJvOwPk8ceowrH8k6Ow3t+TraWmhYO950=
github.com/uhppoted/uhppoted-lib v0.8.5/go.mod h1:euK2cLO934w0GDgvvnWMjYNtZ29K1xSMrMse6THOzDQ=
github.com/uhppoted/uhppoted-lib v0.8.6-0.20230714155133-57e68f2d1360 h1:XaVqmMmjwskTrX6iCdUl2I4ezrvuoA/yhLzf/455E10=
Expand Down Expand Up @@ -118,3 +120,5 @@ github.com/uhppoted/uhppoted-lib v0.8.9-0.20240524171653-86bb80223c95 h1:XRdwZQU
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240524171653-86bb80223c95/go.mod h1:X60HhO4iKqIw+J+r0Rh4OkAzpMbhLzo+7QELXKDQowM=
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240527174018-4ff1fd4a0224 h1:DYkZ77CR3eVcfTatc9JLSPyVQEcOviJbA2lysPjbVSI=
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240527174018-4ff1fd4a0224/go.mod h1:3CvWWsUiXmFh4jTzF+NXeWTMeaHiqkIDLOxoKQ0iJd8=
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240528151010-a3cffa5b9381 h1:QuAU374rlmn9vBraZ6XbywgRLpIQw3m0yYMwj8bR8Cc=
github.com/uhppoted/uhppoted-lib v0.8.9-0.20240528151010-a3cffa5b9381/go.mod h1:Yf3cROHpYsNUX7IJWsZncCQVwyG4eppUWQEs1ST6tv0=
3 changes: 1 addition & 2 deletions simulator/UT0311L04/UTC0311L04_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ func TestHandleGetListener(t *testing.T) {

response := messages.GetListenerResponse{
SerialNumber: 12345,
Address: net.IPv4(10, 0, 0, 10),
Port: 43210,
AddrPort: netip.MustParseAddrPort("10.0.0.10:43210"),
}

testHandle(&request, &response, t)
Expand Down
13 changes: 4 additions & 9 deletions simulator/UT0311L04/get_listener.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package UT0311L04

import (
"net"
"net/netip"

"github.com/uhppoted/uhppote-core/messages"
)
Expand All @@ -11,19 +11,14 @@ func (s *UT0311L04) getListener(request *messages.GetListenerRequest) (*messages
return nil, nil
}

address := net.IPv4(0, 0, 0, 0)
port := uint16(0)

addr := netip.MustParseAddrPort("0.0.0.0:0")
if s.Listener.IsValid() {
addr := s.Listener.Addr().As4()
address = net.IPv4(addr[0], addr[1], addr[2], addr[3])
port = s.Listener.Port()
addr = s.Listener
}

response := messages.GetListenerResponse{
SerialNumber: s.SerialNumber,
Address: address,
Port: port,
AddrPort: addr,
}

return &response, nil
Expand Down

0 comments on commit c91db9e

Please sign in to comment.