Skip to content

Commit ef600b2

Browse files
committed
Traceroute reply
- `measurement/traceroute/reply`: Version 4610 adds "Unrecognized error codes are represented as integers" for `Err`, add support by converting error codes back to string (ref #25) - Add Go mod files - Fix a bit of code formatting
1 parent 1f3c710 commit ef600b2

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ SOURCES := $(wildcard *.go) \
66
$(wildcard measurement/http/*.go) \
77
$(wildcard measurement/ntp/*.go) \
88
$(wildcard measurement/sslcert/*.go) \
9-
$(wildcard request/*.go) \
10-
$(wildcard request/probe/*.go)
9+
$(wildcard request/*.go) \
10+
$(wildcard request/probe/*.go)
1111

1212
EXAMPLE_SOURCES = $(wildcard example/*/*.go)
1313

atlaser.go

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Package ripeatlas implements bindings for RIPE Atlas.
2323
The Atlaser is the interface to access RIPE Atlas and there are a few
2424
different ways to do so, for example read measurement results from a
2525
JSON file:
26+
2627
a := ripeatlas.Atlaser(ripeatlas.NewFile())
2728
c, err := a.MeasurementResults(ripeatlas.Params{"file": name})
2829
if err != nil {

go.mod

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module github.com/DNS-OARC/ripeatlas
2+
3+
go 1.19
4+
5+
require (
6+
github.com/graarh/golang-socketio v0.0.0-20170510162725-2c44953b9b5f
7+
github.com/miekg/dns v1.1.50
8+
)
9+
10+
require (
11+
github.com/gorilla/websocket v1.5.0 // indirect
12+
golang.org/x/mod v0.4.2 // indirect
13+
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 // indirect
14+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
15+
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 // indirect
16+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
17+
)

go.sum

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
2+
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
3+
github.com/graarh/golang-socketio v0.0.0-20170510162725-2c44953b9b5f h1:utzdm9zUvVWGRtIpkdE4+36n+Gv60kNb7mFvgGxLElY=
4+
github.com/graarh/golang-socketio v0.0.0-20170510162725-2c44953b9b5f/go.mod h1:8gudiNCFh3ZfvInknmoXzPeV17FSH+X2J5k2cUPIwnA=
5+
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
6+
github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
7+
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
8+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
9+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
10+
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
11+
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
12+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
13+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
14+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
15+
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985 h1:4CSI6oo7cOjJKajidEljs9h+uP0rRZBPPPhcCbj5mw8=
16+
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
17+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
18+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
19+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
20+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
21+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
22+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
23+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
24+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
25+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
26+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
27+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
28+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
29+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
30+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
31+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
32+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
33+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
34+
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 h1:BonxutuHCTL0rBDnZlKjpGIQFTjyUVTexFOdWkB6Fg0=
35+
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
36+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
37+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
38+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
39+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

measurement/traceroute/reply.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727
// Traceroute reply.
2828
type Reply struct {
2929
data struct {
30-
X string `json:"x"`
31-
Err string `json:"err"`
30+
X string `json:"x"`
31+
Err string
32+
_err interface{} `json:"err"`
3233
From string `json:"from"`
3334
Ittl int `json:"ittl"`
3435
Edst string `json:"edst"`
@@ -50,6 +51,14 @@ func (r *Reply) UnmarshalJSON(b []byte) error {
5051
if err := json.Unmarshal(b, &r.data); err != nil {
5152
return fmt.Errorf("%s for %s", err.Error(), string(b))
5253
}
54+
switch _err := r.data._err.(type) {
55+
case string:
56+
r.data.Err = _err
57+
case int:
58+
r.data.Err = fmt.Sprintf("%v", _err)
59+
default:
60+
return fmt.Errorf("err type %T unexpected for %s", r.data._err, string(b))
61+
}
5362

5463
if r.data.Icmpext != nil {
5564
r.icmpext = &Icmpext{}

0 commit comments

Comments
 (0)