1
0
mirror of https://github.com/fumiama/go-nd-portal.git synced 2026-06-05 00:10:25 +08:00

20 Commits

Author SHA1 Message Date
chasey-dev
ca2606c88b refactor: handle response error message with unified logic (#10) 2025-12-10 15:31:55 +08:00
chasey-dev
1ed57b1209 docs: update README.md about sh login types (#7) v0.3.1 2025-09-03 17:06:13 +08:00
chasey-dev
4d9b9e1886 feat: support sh campus login (#6)
- added login type: sh-edu, sh-dx, sh-cmcc
2025-09-03 12:55:51 +08:00
chasey-dev
f2459dd8d9 refactor: auto get client ip from challenge response (#5)
* refactor: auto get client ip from challenge response
Since `outip()` was not working properly on devices getting local IP addresses behind a router, we should refactor this.
After analyzing the auth process, it is shown that  the challenge response includes key `client_ip` which is the real public IP address with key `ip` not specified in request.
- removed `outip()`
- added rsp key `ClientIP` to get client ip from challenge rsp

* style: trim code

* style: fix spelling issues

* refactor: create `portal_test.go` to handle portal tests separately

* feature: add `ResolveLocalClientIP()` and its test case

* optimize: resolve ClientIP locally when cant be get from challenge response
v0.3.0
2025-09-01 22:33:57 +08:00
chasey-dev
32fdf3ae90 feat: auto select server IP when not specified (#4) v0.2.1 2025-05-21 17:09:57 +09:00
源文雨
81957d1c29 chore: update ci version v0.2.0 2025-05-18 21:08:36 +09:00
github-actions[bot]
7b844523eb chore(lint): 改进代码样式 (#2)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-18 21:04:57 +09:00
chasey-dev
0fb9dda436 feat: support new dorm area login (#1)
## Pull Request Overview

This PR enhances the login CLI to support a new “dorm area” and replaces the old `-x` flag with two new flags for server host (`-s`) and login type (`-t`).  
- Introduces a `LoginType` enum and dynamic domain/AcID mapping in `Portal`.  
- Refactors URL construction to use `go-querystring` and JSON-encoded user info.  
- Updates tests and removes the hard-coded `-x` logic in `cmd/main.go`.

### Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

<details>
<summary>Show a summary per file</summary>

| File                   | Description                                                     |
| ---------------------- | --------------------------------------------------------------- |
| portal/server_test.go  | Updated tests to supply the new `loginType` parameter and use `GetUserInfo`. |
| portal/server.go       | Reworked URL builders (`GetChallengeURL`, `GetLoginURL`), JSON `UserInfo`, and dynamic flags. |
| portal/portal.go       | Added `LoginType`, `ToDomainAcID`, updated `NewPortal`, `GetChallenge`, and `Login` signatures. |
| cmd/main.go            | Removed `-x`, added `-s`/`-t` flags, wired them through to `Portal`. |
| base64/base64.go       | Fixed typo in package comment.                                  |
| go.mod                 | Added `github.com/google/go-querystring` dependency.            |
</details>



<details>
<summary>Comments suppressed due to low confidence (4)</summary>

**base64/base64.go:1**
* Typo in the comment: 'talbe' should be 'table'.
```
// Package base64 with customized talbe
```
**portal/portal.go:53**
* New login types (`qsh-dx`, `qshd-dx`, `qshd-cmcc`) were added but there are no unit tests verifying `ToDomainAcID` returns the correct domain and AC ID for each, or that invalid types produce an error. Consider adding tests for each mapping and an invalid case.
```
func (lt LoginType) ToDomainAcID() (string, string, error) {
```
**cmd/main.go:54**
* [nitpick] The flag variables `s` and `t` are not descriptive. Consider renaming them to `server` and `loginType` (or similar) to improve clarity for users and maintainers.
```
s := flag.String("s", portal.PortalServerIPQsh, "login host")
```
**cmd/main.go:106**
* The call to `netip.ParseAddr` requires importing the `net/netip` package, but `netip` is not imported. Add `import "net/netip"` to fix the compile error.
```
_, err := netip.ParseAddr(*s)
```
</details>

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
2025-05-18 21:03:34 +09:00
源文雨
2371c0a51b chore: fix some lints 2025-05-17 16:36:08 +09:00
源文雨
e608d07157 chore: fix some lints 2025-05-17 16:27:32 +09:00
源文雨
0090b5f59f feat: add lints 2025-05-17 16:24:03 +09:00
源文雨
ca72da0c06 support dx login v0.1.3 2022-12-06 12:58:38 +08:00
源文雨
10639b07ec Update README.md 2022-11-26 17:03:08 +08:00
源文雨
7c9d2e2901 drop fb v0.1.2 2022-11-26 16:38:43 +08:00
源文雨
b152c56760 优化workflow v0.1.1 2022-11-26 15:55:10 +08:00
源文雨
91808d70b9 fin v0.1.0 2022-11-26 15:47:31 +08:00
源文雨
51de023bdb fix 2022-11-26 00:43:57 +08:00
源文雨
be33e0df7e fix 2022-11-26 00:41:15 +08:00
源文雨
8743bf9b5d init 2022-11-26 00:39:38 +08:00
源文雨
2dd688a7d9 Initial commit 2022-11-25 19:33:53 +08:00