This is a creation in Article, where the information may have evolved or changed.
Start thanks to the author of Sspanel Orvice great God! " reprint Please specify "
Bo Master recently in the construction of Sspanel v3, the middle pit really a lot of, I turn back to add, SS server side I chose Orvice shadowsocks-go mu version, because the author is based on the mechanism of flow control, in fact, unscrupulous traders are through time control (233), So I'm going to make a change based on the author and add the time limit.
In the previous blog I implemented the MySQL API modification, this one is the Web API. At first I thought Orvice is in the PHP API control, see the API discovery is not (or WEBAPI direct control, modify convenient = =), database modification, etc. please go to see a portal
Find the user struct, path shadowsocks-go-mu\mu\webapi\user.go
Structure modification, note that the field and JSON fields here cannot be the same, otherwise it will not resolve, the first letter uppercase can be
Type User struct {id int ' JSON: ' ID ' ' Port int ' JSON: ' Port ' ' Passwd string ' JSON: ' Passwd ' Method string ' JSON: ' method ' ' Enable int ' JSON: ' Enable ' ' transferenable Int64 ' JSON: ' transfer_enable ' ' U Int64 ' json: "U" ' d Int64 ' JSON: "D" '//End time End_time Int64 ' JSON: "End_time" '// Now time Now_time Int64 ' JSON: "Now_time" '//package type Package_type int ' JSON: "Package_type" '}
Control method Modification
Func (U User) isenable () bool {if u.enable = = 0 {return false}if u.transferenable < (u.u + u.d) {return false}//if expired, deactivated User if U.now_time > u.end_time {return False}return true}
Because the now_time here need to be obtained from the background, it is also necessary to modify the Sspanel code (local read time will be at risk of inconsistent time, not recommended)
PHP MVC code changed very painful = = because the SQL operation is modular, it needs to be lazy, find the API file, path app/controllers/mu/usercontroller.php, modify the Index method code
User List public function Index ($request, $response, $args) { $users = User::all (); Returns the current timestamp to the data in foreach ($users as $user) { $user->now_time = time (); } $res = [ "ret" + = 1, "msg" = "OK", "data" and "= $users ]; return $this->echojson ($response, $res); }
The user does not have the Now_time field in the original code, so you also need to add the Now_time field to the user table, put it behind the end_time, type int, and the default value is arbitrary.
After the change, the PHP directly to your site root directory to manually modify the
in doubt, you can add group discussion, group number 256950656