File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 8
8
"os"
9
9
"time"
10
10
"x-ui/logger"
11
+ "x-ui/util/common"
11
12
)
12
13
13
14
type WarpService struct {
@@ -150,13 +151,23 @@ func (s *WarpService) SetWarpLicense(license string) (string, error) {
150
151
return "" , err
151
152
}
152
153
154
+ var response map [string ]interface {}
155
+ err = json .Unmarshal (buffer .Bytes (), & response )
156
+ if err != nil {
157
+ return "" , err
158
+ }
159
+ if response ["success" ] == false {
160
+ errorArr , _ := response ["errors" ].([]interface {})
161
+ errorObj := errorArr [0 ].(map [string ]interface {})
162
+ return "" , common .NewError (errorObj ["code" ], errorObj ["message" ])
163
+ }
164
+
153
165
warpData ["license_key" ] = license
154
166
newWarpData , err := json .MarshalIndent (warpData , "" , " " )
155
167
if err != nil {
156
168
return "" , err
157
169
}
158
170
s .SettingService .SetWarp (string (newWarpData ))
159
- println (string (newWarpData ))
160
171
161
172
return string (newWarpData ), nil
162
173
}
You can’t perform that action at this time.
0 commit comments