diff --git a/tor/torProvider.go b/tor/torProvider.go index a69254b..a43fe32 100644 --- a/tor/torProvider.go +++ b/tor/torProvider.go @@ -114,6 +114,10 @@ func (tp *torProvider) GetInfo(onion string) (map[string]string, error) { } } + if cirucitID == "" { + return nil, errors.New("could not find circuit") + } + var hops []string for _, circuit := range circuits { if circuit.Key == "circuit-status" { diff --git a/tor/torProvider_test.go b/tor/torProvider_test.go index e7104a1..1630bf4 100644 --- a/tor/torProvider_test.go +++ b/tor/torProvider_test.go @@ -43,6 +43,29 @@ func TestTorProvider(t *testing.T) { t.Logf("progress: %v", progress) } + // Test opening the OP Server + _, _, err = acn.Open("isbr2t6bflul2zyi6hjtnuezb2xvfr42svzjg2q3gyqfgg3wmnrbkkqd") + + if err == nil { + info, err := acn.GetInfo("isbr2t6bflul2zyi6hjtnuezb2xvfr42svzjg2q3gyqfgg3wmnrbkkqd") + if err != nil { + t.Fatalf("could not find info for OP server %v", err) + } + cinfo, exists := info["circuit"] + if !exists { + t.Fatalf("could not find circuit info for OP server %v", err) + } + t.Logf("Found Cicurit Info %v", cinfo) + + _, err = acn.GetInfo("not_a_real_onion") + if err == nil { + t.Fatalf("GetInfo for non existant onion should have errored") + } + + } else { + t.Fatalf("could not connect to OP server %v", err) + } + // Should skip without blocking... acn.Restart() acn.Restart()