mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-18 23:01:23 +00:00
feat(proxy): allow configurable probe targets
This commit is contained in:
4 files changed
+100
-5
No files matched your search
@@ -166,6 +166,22 @@ func (s *ProxyProbeServiceSuite) TestParseIPify_NoIP() {
|
||||
require.ErrorContains(s.T(), err, "no IP found")
|
||||
}
|
||||
|
||||
func (s *ProxyProbeServiceSuite) TestParseChatGPTTrace_Success() {
|
||||
body := []byte("fl=abc\nh=chatgpt.com\nip=203.0.113.5\nts=1700000000\nloc=US\ntz=UTC\n")
|
||||
info, latencyMs, err := s.prober.parseChatGPTTrace(body, 320)
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), int64(320), latencyMs)
|
||||
require.Equal(s.T(), "203.0.113.5", info.IP)
|
||||
require.Equal(s.T(), "US", info.CountryCode)
|
||||
}
|
||||
|
||||
func (s *ProxyProbeServiceSuite) TestParseChatGPTTrace_NoIP() {
|
||||
body := []byte("fl=abc\nh=chatgpt.com\nloc=US\n")
|
||||
_, _, err := s.prober.parseChatGPTTrace(body, 100)
|
||||
require.Error(s.T(), err)
|
||||
require.ErrorContains(s.T(), err, "chatgpt-trace: no ip= found")
|
||||
}
|
||||
|
||||
func TestProxyProbeServiceSuite(t *testing.T) {
|
||||
suite.Run(t, new(ProxyProbeServiceSuite))
|
||||
}
|
||||
Reference in new issue
Block a user