mirror of
https://github.com/Alexey71/opera-proxy.git
synced 2026-05-13 22:20:59 +00:00
WIP
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
module github.com/Snawoot/opera-proxy
|
module github.com/Snawoot/opera-proxy
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/Snawoot/go-http-digest-auth-client v1.0.0 // indirect
|
||||||
|
golang.org/x/net v0.0.0-20210324205630-d1beb07c2056 // indirect
|
||||||
|
)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
github.com/Snawoot/go-http-digest-auth-client v1.0.0 h1:1xNR4muFtT+PjP1Z2QAZG0fooszF8nWuYv6QlTKgi1E=
|
||||||
|
github.com/Snawoot/go-http-digest-auth-client v1.0.0/go.mod h1:WiwNiPXTRGyjTGpBtSQJlM2wDPRRPpFGhMkMWpV4uqg=
|
||||||
|
golang.org/x/net v0.0.0-20210324205630-d1beb07c2056 h1:sANdAef76Ioam9aQUUdcAqricwY/WUaMc4+7LY4eGg8=
|
||||||
|
golang.org/x/net v0.0.0-20210324205630-d1beb07c2056/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package seclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
|
|
||||||
|
dac "github.com/Snawoot/go-http-digest-auth-client"
|
||||||
|
"golang.org/x/net/publicsuffix"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SEEndpoints struct {
|
||||||
|
RegisterSubscriber string
|
||||||
|
SubscriberLogin string
|
||||||
|
RegisterDevice string
|
||||||
|
GeoList string
|
||||||
|
Discover string
|
||||||
|
}
|
||||||
|
|
||||||
|
var DefaultSEEndpoints = SEEndpoints{
|
||||||
|
RegisterSubscriber: "https://api.sec-tunnel.com/v4/register_subscriber",
|
||||||
|
SubscriberLogin: "https://api.sec-tunnel.com/v4/subscriber_login",
|
||||||
|
RegisterDevice: "https://api.sec-tunnel.com/v4/register_device",
|
||||||
|
GeoList: "https://api.sec-tunnel.com/v4/geo_list",
|
||||||
|
Discover: "https://api.sec-tunnel.com/v4/discover",
|
||||||
|
}
|
||||||
|
|
||||||
|
type SESettings struct {
|
||||||
|
ClientVersion string
|
||||||
|
OperatingSystem string
|
||||||
|
APIUsername string
|
||||||
|
APISecret string
|
||||||
|
Endpoints SEEndpoints
|
||||||
|
}
|
||||||
|
|
||||||
|
var DefaultSESettings = SESettings{
|
||||||
|
ClientVersion: "Stable 74.0.3911.232",
|
||||||
|
OperatingSystem: "Windows",
|
||||||
|
Endpoints: DefaultSEEndpoints,
|
||||||
|
}
|
||||||
|
|
||||||
|
type SEClient struct {
|
||||||
|
HttpClient *http.Client
|
||||||
|
Settings SESettings
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instantiates SurfEasy client with default settings and given API keys.
|
||||||
|
// Optional `transport` parameter allows to override HTTP transport used
|
||||||
|
// for HTTP calls
|
||||||
|
func NewSEClient(apiUsername, apiSecret string, transport http.RoundTripper) (*SEClient, error) {
|
||||||
|
if transport == nil {
|
||||||
|
transport = http.DefaultTransport
|
||||||
|
}
|
||||||
|
|
||||||
|
jar, err := cookiejar.New(&cookiejar.Options{
|
||||||
|
PublicSuffixList: publicsuffix.List,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SEClient{
|
||||||
|
HttpClient: &http.Client{
|
||||||
|
Transport: dac.NewDigestTransport(apiUsername, apiSecret, transport),
|
||||||
|
Jar: jar,
|
||||||
|
},
|
||||||
|
Settings: DefaultSESettings,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user