Skip to content

Commit

Permalink
fix(quicping): support URLs with an IPv6 address (#1192)
Browse files Browse the repository at this point in the history
Closes ooni/probe#2546


---------

Co-authored-by: Simone Basso <[email protected]>
  • Loading branch information
Lanius-collaris and bassosimone authored Oct 6, 2023
1 parent cf67bdb commit 16f175b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions internal/experiment/quicping/quicping.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (

const (
testName = "quicping"
testVersion = "0.1.0"
testVersion = "0.1.1"
)

// Config contains the experiment configuration.
Expand Down Expand Up @@ -228,12 +228,18 @@ func (m *Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
sess := args.Session

host := string(measurement.Input)
var port = ""
// allow URL input
if u, err := url.ParseRequestURI(host); err == nil {
host = u.Host
host = u.Hostname()
port = u.Port()
}
service := net.JoinHostPort(host, m.config.port())
udpAddr, err := net.ResolveUDPAddr("udp4", service)
var service string
if port == "" {
port = m.config.port()
}
service = net.JoinHostPort(host, port)
udpAddr, err := net.ResolveUDPAddr("udp", service)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/experiment/quicping/quicping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNewExperimentMeasurer(t *testing.T) {
if measurer.ExperimentName() != "quicping" {
t.Fatal("unexpected name")
}
if measurer.ExperimentVersion() != "0.1.0" {
if measurer.ExperimentVersion() != "0.1.1" {
t.Fatal("unexpected version")
}
}
Expand Down

0 comments on commit 16f175b

Please sign in to comment.