From 632ca55ee90e61a37104a4b91c564352d701e20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Fri, 5 Nov 2021 20:07:36 +0800 Subject: [PATCH] fix(kick, info): move to https and fix regex about mac info(#39) --- pkg/handler/dashboard.go | 12 ++++++------ pkg/handler/ipgw.go | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/handler/dashboard.go b/pkg/handler/dashboard.go index fb3e437..e36f94a 100644 --- a/pkg/handler/dashboard.go +++ b/pkg/handler/dashboard.go @@ -32,7 +32,7 @@ func (d *DashboardHandler) Login(account *model.Account) error { if err != nil { return err } - _, err = d.client.Get("http://ipgw.neu.edu.cn:8800/sso/neusoft/index") // 统一认证获取cookie + _, err = d.client.Get("https://ipgw.neu.edu.cn:8800/sso/neusoft/index") // 统一认证获取cookie if err != nil { return err } @@ -40,7 +40,7 @@ func (d *DashboardHandler) Login(account *model.Account) error { } func (d *DashboardHandler) fetchDashboardIndexBody() (string, error) { - resp, err := d.client.Get("http://ipgw.neu.edu.cn:8800/home") + resp, err := d.client.Get("https://ipgw.neu.edu.cn:8800/home") if err != nil { return "", err } @@ -48,7 +48,7 @@ func (d *DashboardHandler) fetchDashboardIndexBody() (string, error) { } func (d *DashboardHandler) fetchDashboardBillsBody(page int) (string, error) { - resp, err := d.client.Get(fmt.Sprintf("http://ipgw.neu.edu.cn:8800/log/check-out?page=%d&per-page=10", page)) + resp, err := d.client.Get(fmt.Sprintf("https://ipgw.neu.edu.cn:8800/log/check-out?page=%d&per-page=10", page)) if err != nil { return "", err } @@ -56,7 +56,7 @@ func (d *DashboardHandler) fetchDashboardBillsBody(page int) (string, error) { } func (d *DashboardHandler) fetchDashboardRechargeBody(page int) (string, error) { - resp, err := d.client.Get(fmt.Sprintf("http://ipgw.neu.edu.cn:8800/log/pay?page=%d&per-page=10", page)) + resp, err := d.client.Get(fmt.Sprintf("https://ipgw.neu.edu.cn:8800/log/pay?page=%d&per-page=10", page)) if err != nil { return "", err } @@ -64,7 +64,7 @@ func (d *DashboardHandler) fetchDashboardRechargeBody(page int) (string, error) } func (d *DashboardHandler) fetchDashboardUsageLogBody(page int) (string, error) { - resp, err := d.client.Get(fmt.Sprintf("http://ipgw.neu.edu.cn:8800/log/detail?page=%d&per-page=10", page)) + resp, err := d.client.Get(fmt.Sprintf("https://ipgw.neu.edu.cn:8800/log/detail?page=%d&per-page=10", page)) if err != nil { return "", err } @@ -148,7 +148,7 @@ func (d *DashboardHandler) GetDevice() ([]Device, error) { if err != nil { return []Device{}, err } - ds, _ := utils.MatchMultiple(regexp.MustCompile(`\d+(.+?)(.+?)`), body) + ds, _ := utils.MatchMultiple(regexp.MustCompile(`\d+(.+?)(.+?).+?`), body) result := make([]Device, len(ds)) for i, device := range ds { result[i] = Device{i, device[2], device[3], device[1]} diff --git a/pkg/handler/ipgw.go b/pkg/handler/ipgw.go index df12dee..c63c76e 100644 --- a/pkg/handler/ipgw.go +++ b/pkg/handler/ipgw.go @@ -143,7 +143,7 @@ func (h *IpgwHandler) ParseBasicInfo() error { func (h *IpgwHandler) Logout() error { req, _ := http.NewRequest("GET", "https://ipgw.neu.edu.cn/cgi-bin/srun_portal?action=logout&username="+h.info.Username, nil) - req.Header.Add("Referer", "http://ipgw.neu.edu.cn/srun_portal_success?ac_id=1") + req.Header.Add("Referer", "https://ipgw.neu.edu.cn/srun_portal_success?ac_id=1") _, err := h.client.Do(req) return err } @@ -160,10 +160,10 @@ func (h *IpgwHandler) IsConnectedAndLoggedIn() (connected bool, loggedIn bool) { func (h *IpgwHandler) Kick(sid string) (bool, error) { once.Do(func() { - h.client.Get("http://ipgw.neu.edu.cn:8800/sso/neusoft/index") + h.client.Get("https://ipgw.neu.edu.cn:8800/sso/neusoft/index") }) // 请求主页 - resp, err := h.client.Get("http://ipgw.neu.edu.cn:8800/home") + resp, err := h.client.Get("https://ipgw.neu.edu.cn:8800/home") if err != nil { return false, err } @@ -171,8 +171,8 @@ func (h *IpgwHandler) Kick(sid string) (bool, error) { // 获取csrf-token token, _ := utils.MatchSingle(regexp.MustCompile(``), body) - req, _ := http.NewRequest("POST", "http://ipgw.neu.edu.cn:8800/home/delete?id="+sid, strings.NewReader("_csrf-8800="+token)) - req.Header.Set("Referer", "http://ipgw.neu.edu.cn:8800/home/index") + req, _ := http.NewRequest("POST", "https://ipgw.neu.edu.cn:8800/home/delete?id="+sid, strings.NewReader("_csrf-8800="+token)) + req.Header.Set("Referer", "https://ipgw.neu.edu.cn:8800/home/index") req.Header.Add("Content-Type", "application/x-www-form-urlencoded") resp, err = h.client.Do(req)