mirror of
https://github.com/Snawoot/opera-proxy.git
synced 2025-09-02 02:30:21 +00:00
seclient: add device_generate_password method
This commit is contained in:
parent
ddc27f34ab
commit
298c91b4b5
2 changed files with 41 additions and 10 deletions
|
@ -62,6 +62,15 @@ type SERegisterDeviceResponse struct {
|
||||||
Status SEStatusPair `json:"return_code"`
|
Status SEStatusPair `json:"return_code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SEDeviceGeneratePasswordData struct {
|
||||||
|
DevicePassword string `json:"device_password"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SEDeviceGeneratePasswordResponse struct {
|
||||||
|
Data SEDeviceGeneratePasswordData `json:"data"`
|
||||||
|
Status SEStatusPair `json:"return_code"`
|
||||||
|
}
|
||||||
|
|
||||||
type SEGeoEntry struct {
|
type SEGeoEntry struct {
|
||||||
Country string `json:"country,omitempty"`
|
Country string `json:"country,omitempty"`
|
||||||
CountryCode string `json:"country_code"`
|
CountryCode string `json:"country_code"`
|
||||||
|
|
|
@ -28,6 +28,7 @@ type SEEndpoints struct {
|
||||||
RegisterSubscriber string
|
RegisterSubscriber string
|
||||||
SubscriberLogin string
|
SubscriberLogin string
|
||||||
RegisterDevice string
|
RegisterDevice string
|
||||||
|
DeviceGeneratePassword string
|
||||||
GeoList string
|
GeoList string
|
||||||
Discover string
|
Discover string
|
||||||
}
|
}
|
||||||
|
@ -36,6 +37,7 @@ var DefaultSEEndpoints = SEEndpoints{
|
||||||
RegisterSubscriber: "https://api.sec-tunnel.com/v4/register_subscriber",
|
RegisterSubscriber: "https://api.sec-tunnel.com/v4/register_subscriber",
|
||||||
SubscriberLogin: "https://api.sec-tunnel.com/v4/subscriber_login",
|
SubscriberLogin: "https://api.sec-tunnel.com/v4/subscriber_login",
|
||||||
RegisterDevice: "https://api.sec-tunnel.com/v4/register_device",
|
RegisterDevice: "https://api.sec-tunnel.com/v4/register_device",
|
||||||
|
DeviceGeneratePassword: "https://api.sec-tunnel.com/v4/device_generate_password",
|
||||||
GeoList: "https://api.sec-tunnel.com/v4/geo_list",
|
GeoList: "https://api.sec-tunnel.com/v4/geo_list",
|
||||||
Discover: "https://api.sec-tunnel.com/v4/discover",
|
Discover: "https://api.sec-tunnel.com/v4/discover",
|
||||||
}
|
}
|
||||||
|
@ -217,6 +219,26 @@ func (c *SEClient) Login(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *SEClient) DeviceGeneratePassword(ctx context.Context) error {
|
||||||
|
var genRes SEDeviceGeneratePasswordResponse
|
||||||
|
err := c.RpcCall(ctx, c.Settings.Endpoints.DeviceGeneratePassword, StrKV{
|
||||||
|
"device_id": c.AssignedDeviceID,
|
||||||
|
}, &genRes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if genRes.Status.Code != SE_STATUS_OK {
|
||||||
|
return fmt.Errorf("API responded with error message: code=%d, msg=\"%s\"",
|
||||||
|
genRes.Status.Code, genRes.Status.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.StateMux.Lock()
|
||||||
|
c.DevicePassword = genRes.Data.DevicePassword
|
||||||
|
c.StateMux.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *SEClient) GetProxyCredentials() (string, string) {
|
func (c *SEClient) GetProxyCredentials() (string, string) {
|
||||||
c.StateMux.RLock()
|
c.StateMux.RLock()
|
||||||
assignedDeviceIDHash := c.AssignedDeviceIDHash
|
assignedDeviceIDHash := c.AssignedDeviceIDHash
|
||||||
|
|
Loading…
Add table
Reference in a new issue