Compare commits

...

129 Commits

Author SHA1 Message Date
Alireza Ahmadi 86379818a2 v1.3.11 2026-02-28 13:28:48 +01:00
Alireza Ahmadi 8a07d2df7e Merge pull request #1033 from alireza0/dependabot/github_actions/actions/upload-artifact-7
Bump actions/upload-artifact from 6 to 7
2026-02-28 02:03:57 +01:00
Alireza Ahmadi 7d63da8be3 Merge pull request #1032 from alireza0/dependabot/github_actions/actions/download-artifact-8
Bump actions/download-artifact from 7 to 8
2026-02-28 02:03:39 +01:00
Alireza Ahmadi 06ee9cfce2 Sing-Box v1.12.23 2026-02-28 02:02:10 +01:00
Alireza Ahmadi 13d475da20 fix crash on restart due to change #1030 2026-02-28 01:52:34 +01:00
dependabot[bot] fbf46a72b0 Bump actions/upload-artifact from 6 to 7
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-27 16:53:23 +00:00
dependabot[bot] 5bb15ff2c9 Bump actions/download-artifact from 7 to 8
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-27 16:53:18 +00:00
Alireza Ahmadi 5812d6a827 fix docker logs and db #1019 2026-02-17 21:14:37 +01:00
Seva 083f19324f Fix directory when running as administrator (#1009)
* Update install-windows.bat

* Update s-ui-windows.bat

* Update install-windows.bat

* Update build-windows.bat
2026-02-17 20:26:16 +01:00
Alireza Ahmadi dd07abf501 fix inbound delete affects on client #1008 2026-02-17 20:08:03 +01:00
Alireza Ahmadi 0202a3e055 v1.3.10 2026-02-13 22:30:33 +01:00
Alireza Ahmadi 66ca82c635 Go v1.25.7 2026-02-13 22:00:23 +01:00
Alireza Ahmadi 85d42ee91c improve converting link to json 2026-02-13 21:49:43 +01:00
Alireza Ahmadi bdc25bb3d6 Add contribution guide
#111
2026-02-12 23:43:51 +01:00
Alireza Ahmadi e6689ae2dc [api] convert sub to Json 2026-02-12 23:29:50 +01:00
Alireza Ahmadi 688e0c3e23 add api checkOutbound #761 2026-02-11 21:52:31 +01:00
Alireza Ahmadi d996e7171b fix: core full stop 2026-02-11 19:13:04 +01:00
Alireza Ahmadi 76e91aa9b8 windows pipeline on tag 2026-02-10 00:11:34 +01:00
Alireza Ahmadi af5bd9f75d v1.3.9 2026-02-10 00:02:29 +01:00
Alireza Ahmadi 0fd36e4e6d Sing-Box v1.12.21 2026-02-10 00:02:07 +01:00
Alireza Ahmadi 0f29e2ad31 [clash] fix ipv6 by simple detection #871 2026-02-09 01:02:29 +01:00
Alireza Ahmadi 4ce3647670 db status data for first page 2026-02-09 00:51:31 +01:00
Alireza Ahmadi 90976cded1 fix dblock on failure #964 2026-02-08 21:19:28 +01:00
Alireza Ahmadi f5714eccee release on tag 2026-02-08 17:17:37 +01:00
Alireza Ahmadi e84f7530e3 v1.3.8 2026-02-08 17:02:02 +01:00
Alireza Ahmadi 63cc7ca957 Sing-Box v1.12.20 2026-02-08 17:01:44 +01:00
Alireza Ahmadi c8432fda54 update dependencies 2026-02-03 21:13:37 +01:00
Alireza Ahmadi 022574a1d7 Merge pull request #975 from alireza0/dependabot/github_actions/actions/checkout-6.0.2
Bump actions/checkout from 6.0.1 to 6.0.2
2026-02-03 20:58:17 +01:00
Alireza Ahmadi 76ab5e2ccc Merge pull request #967 from alireza0/dependabot/github_actions/actions/cache-5
Bump actions/cache from 4 to 5
2026-02-03 20:57:55 +01:00
Alireza Ahmadi 10ba989175 Merge pull request #966 from alireza0/dependabot/github_actions/actions/upload-artifact-6
Bump actions/upload-artifact from 5 to 6
2026-02-03 20:57:39 +01:00
Alireza Ahmadi 46434a6b3f Merge pull request #965 from alireza0/dependabot/github_actions/actions/download-artifact-7
Bump actions/download-artifact from 6 to 7
2026-02-03 20:57:23 +01:00
dependabot[bot] c5e07ba076 Bump actions/checkout from 6.0.1 to 6.0.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6.0.1...v6.0.2)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-22 16:53:56 +00:00
Alireza Ahmadi d5c6bdaeff Merge pull request #962 from Kagashini/fix/link-parameter-ordering
Fixing Parameter Order in Generated Links
2026-01-09 20:50:29 +01:00
dependabot[bot] f69b55f721 Bump actions/cache from 4 to 5
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 16:09:43 +00:00
dependabot[bot] 3c9d178709 Bump actions/upload-artifact from 5 to 6
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 16:09:39 +00:00
dependabot[bot] 14013b7d70 Bump actions/download-artifact from 6 to 7
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 16:09:31 +00:00
Anem 9d367fb83d refactor(genLink): replace map with struct for link params 2026-01-05 15:35:03 +08:00
Alireza Ahmadi 0ef5db4846 [feat] download singbox config #938 #957 2026-01-04 17:36:47 +01:00
Alireza Ahmadi 94cc29edf5 Merge pull request #947 from sky22333/main
Fix the issue where the default IP lookup URL is inaccessible on some networks
2026-01-04 16:46:34 +01:00
Alireza Ahmadi 40e2b4cc8a sub header enhancement 2026-01-04 16:38:25 +01:00
Alireza Ahmadi 2b0006f8c8 downgrade quic-go 2026-01-04 01:08:38 +01:00
Alireza Ahmadi 216a76051e Merge pull request #937 from chaosoffire-org/feature-random
fix(security): use CSPRNG (crypto/rand) for random number generation
2026-01-03 23:49:43 +01:00
Alireza Ahmadi a0d7bcc829 Merge pull request #926 from Kagashini/head-request-support
feat(sub): add HEAD method support for sub resource
2026-01-03 23:47:37 +01:00
Alireza Ahmadi 87e3118d6b update dependencies 2026-01-03 23:29:29 +01:00
Alireza Ahmadi 9bc4fe843b add nftables to docker image #872 2026-01-03 23:09:36 +01:00
Alireza Ahmadi b779e3b825 Merge pull request #924 from alireza0/dependabot/github_actions/actions/checkout-6.0.1
Bump actions/checkout from 5.0.0 to 6.0.1
2026-01-03 20:20:58 +01:00
Alireza Ahmadi 4e97afebab Merge pull request #882 from alireza0/dependabot/github_actions/actions/download-artifact-6
Bump actions/download-artifact from 5 to 6
2026-01-03 20:20:35 +01:00
Alireza Ahmadi 3de228ebcd Merge pull request #880 from alireza0/dependabot/github_actions/actions/upload-artifact-5
Bump actions/upload-artifact from 4 to 5
2026-01-03 20:20:03 +01:00
Alireza Ahmadi abd1c378d5 Merge pull request #863 from alireza0/dependabot/github_actions/actions/setup-node-6
Bump actions/setup-node from 5 to 6
2026-01-03 20:19:48 +01:00
Alireza Ahmadi de7197cc58 update deps 2026-01-03 20:18:32 +01:00
starry 7a4c010a45 Fetch IP address concurrently using multiple endpoints 2025-12-27 06:08:26 +08:00
Chaosoffire 09e94c6213 refactor: replace math/rand with crypto/rand for secure generation
- Updated `common.Random` and added `common.RandomInt` to use `crypto/rand` for cryptographically secure random number generation.
- Added a thread-safe fallback to `math/rand` in case of system entropy failure.
- Optimized `allSeq` initialization by using a rune slice literal instead of a loop in `init()`.
- Refactored `util/outJson.go` to use the new `common.RandomInt`, removing the direct dependency on `math/rand`.
2025-12-15 21:43:33 +08:00
Anem fc88f5a509 feat(sub): add HEAD method support for sub resource
- Implement HEAD method for retrieving sub resource metadata for some clients (example: Karing)
2025-12-05 21:38:30 +08:00
dependabot[bot] 1c34e146c1 Bump actions/checkout from 5.0.0 to 6.0.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 5.0.0 to 6.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5.0.0...v6.0.1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-02 16:43:49 +00:00
dependabot[bot] de30e17707 Bump actions/download-artifact from 5 to 6
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-27 16:56:13 +00:00
dependabot[bot] 7a9f3196c7 Bump actions/upload-artifact from 4 to 5
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-27 16:29:22 +00:00
Alireza Ahmadi 65e51f8aea fix ineffassign 2025-10-26 20:22:33 +01:00
dependabot[bot] d31a78b625 Bump actions/setup-node from 5 to 6
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5 to 6.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-14 16:10:46 +00:00
Alireza Ahmadi d6c4d9a497 remove default docker volume #853 2025-10-12 16:51:39 +02:00
Alireza Ahmadi 7b979b95d4 ech for clash sub #770 2025-10-04 22:21:40 +02:00
Alireza Ahmadi 64979e6725 build on tag as well 2025-10-04 22:20:29 +02:00
Alireza Ahmadi 0e3e2d0b18 v1.3.7 2025-09-28 00:09:18 +02:00
Alireza Ahmadi 6d52ad13c5 [clash sub] support shadowsocks #838 2025-09-27 22:32:02 +02:00
Alireza Ahmadi 7c406cfd1c Merge pull request #830 from alireza0/dependabot/go_modules/github.com/gin-gonic/gin-1.11.0
Bump github.com/gin-gonic/gin from 1.10.1 to 1.11.0
2025-09-27 22:06:34 +02:00
Alireza Ahmadi c5ccfb6ead fix(config): Handle null alterId in VMess proxy config (#842)
* fix(config): Gracefully handle null alterId in proxy configurations

* Fix wrong AI based changes

---------

Co-authored-by: Kittros <yuan364299311@gmail.com>
2025-09-27 22:06:17 +02:00
dependabot[bot] 5aa5393ada Bump github.com/gin-gonic/gin from 1.10.1 to 1.11.0
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.10.1 to 1.11.0.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.10.1...v1.11.0)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-version: 1.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-22 16:25:16 +00:00
Alireza Ahmadi 15d171f94e new donation link 2025-09-19 00:12:22 +02:00
Alireza Ahmadi 7751c8fce0 go package 2025-09-18 23:19:56 +02:00
Alireza Ahmadi 9d1ad833f9 v1.3.6 2025-09-13 13:20:41 +02:00
Alireza Ahmadi e6f7354ce7 sing-box v1.12.8 2025-09-13 13:19:58 +02:00
Alireza Ahmadi a2c3033f5a fix hy speed on links #801 2025-09-13 13:15:09 +02:00
Alireza Ahmadi 03cda07c9d fix queryEscape parts in links #806 2025-09-13 12:52:33 +02:00
Alireza Ahmadi fb999b4ee8 v1.3.5 2025-09-12 00:42:39 +02:00
Alireza Ahmadi e3ebfcf721 bump packages 2025-09-12 00:39:58 +02:00
Alireza Ahmadi 33071deb53 Merge pull request #782 from alireza0/dependabot/github_actions/actions/setup-go-6
Bump actions/setup-go from 5 to 6
2025-09-12 00:37:45 +02:00
Alireza Ahmadi 9b3b8d4540 Merge pull request #783 from alireza0/dependabot/github_actions/actions/setup-node-5
Bump actions/setup-node from 4 to 5
2025-09-12 00:37:32 +02:00
Alireza Ahmadi 98bf124078 sing-box v1.12.5 2025-09-12 00:24:13 +02:00
Alireza Ahmadi abc73a6525 fix external link on tls change 2025-09-12 00:19:51 +02:00
Alireza Ahmadi 2276175354 reality support links #794 2025-09-12 00:19:30 +02:00
Alireza Ahmadi 7f24735677 fix hysteria link generator #801 2025-09-11 23:23:58 +02:00
Alireza Ahmadi 4d1544864d go 1.25.1 2025-09-11 21:10:56 +02:00
Alireza Ahmadi 4aadee7ca0 fix ipv6 hostname #789 2025-09-09 22:30:07 +02:00
Alireza Ahmadi 6aba1354d5 fix client api error handling #781 2025-09-04 19:56:56 +02:00
dependabot[bot] 63b229143d Bump actions/setup-node from 4 to 5
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 5.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-04 16:10:29 +00:00
dependabot[bot] f861950c50 Bump actions/setup-go from 5 to 6
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-04 16:10:26 +00:00
Alireza Ahmadi 97d1694bfa fix numbered external links #774 2025-09-04 00:47:58 +02:00
Alireza Ahmadi 2d28d9b409 v1.3.4 2025-09-01 01:06:51 +02:00
Alireza Ahmadi 560c41acbe disable traffic charts if set to zero 2025-08-30 02:11:43 +02:00
Alireza Ahmadi e3c33bf649 sing-box v1.12.4 2025-08-30 01:20:38 +02:00
Alireza Ahmadi 216db63551 fix reality link to clash sub #766 2025-08-29 23:28:00 +02:00
Alireza Ahmadi 05d8a6bf85 Merge pull request #757 from Peter1303/main
update: docker run command
2025-08-26 20:22:45 +02:00
PeterPan 1e6c2b9598 update: docker run command 2025-08-25 11:35:00 +08:00
Alireza Ahmadi f006323f54 remove OS version dependency 2025-08-21 13:39:33 +02:00
Alireza Ahmadi f3bfe9bb9a v1.3.3 2025-08-21 13:10:53 +02:00
Alireza Ahmadi ffbab9682a sing-box v1.12.3 2025-08-21 12:28:56 +02:00
Alireza Ahmadi 123813dc90 fix build for windows 2025-08-21 03:47:37 +02:00
Alireza Ahmadi 7bc7468cf3 build for windows #374 2025-08-20 22:49:00 +02:00
Alireza Ahmadi 12addde548 build by musl instead of glibc 2025-08-20 21:29:49 +02:00
Alireza Ahmadi e54cca19fa go v1.25.0 2025-08-20 20:45:44 +02:00
Alireza Ahmadi a67ec6f58e sing-box v1.12.2 2025-08-20 20:45:19 +02:00
Alireza Ahmadi f913591af0 Merge pull request #732 from alireza0/dependabot/github_actions/actions/checkout-5.0.0
Bump actions/checkout from 4.2.2 to 5.0.0
2025-08-20 20:02:22 +02:00
Alireza Ahmadi 38f7c131a2 Merge pull request #722 from alireza0/dependabot/go_modules/github.com/sagernet/sing-0.7.5
Bump github.com/sagernet/sing from 0.7.0-beta.2 to 0.7.5
2025-08-20 20:02:10 +02:00
Alireza Ahmadi 7c0478d7f4 clashsub: fix tuic missing data #738 2025-08-20 02:38:35 +02:00
Alireza Ahmadi b26aa8d53c add alpn to vmess link #740 2025-08-17 12:36:23 +02:00
dependabot[bot] fb12a27d62 Bump actions/checkout from 4.2.2 to 5.0.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.2 to 5.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4.2.2...v5.0.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-11 23:11:22 +00:00
Alireza Ahmadi 82c7b43f06 update compatibility docs and checks 2025-08-10 13:37:01 +02:00
Alireza Ahmadi 05880ed3b3 add api endpoint for services 2025-08-09 14:04:37 +02:00
dependabot[bot] 1b13fd6839 Bump github.com/sagernet/sing from 0.7.0-beta.2 to 0.7.5
Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.7.0-beta.2 to 0.7.5.
- [Commits](https://github.com/sagernet/sing/compare/v0.7.0-beta.2...v0.7.5)

---
updated-dependencies:
- dependency-name: github.com/sagernet/sing
  dependency-version: 0.7.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 16:28:06 +00:00
Alireza Ahmadi 44fd5f767b v1.3.2 2025-08-07 12:44:12 +02:00
Alireza Ahmadi 9135033dfd fix s-ui script on oracle linux #680 2025-08-07 10:09:08 +02:00
Alireza Ahmadi b1a61584b1 Merge pull request #712 from alireza0/dependabot/github_actions/actions/download-artifact-5
Bump actions/download-artifact from 4 to 5
2025-08-07 00:44:48 +02:00
Alireza Ahmadi b2a0ccfe02 fix ss in json sub 2025-08-07 00:35:12 +02:00
Alireza Ahmadi 590f6871af fix remark on ss link 2025-08-07 00:34:30 +02:00
Alireza Ahmadi 282a24b8fc add sniff in default routing rule #708 2025-08-07 00:16:58 +02:00
dependabot[bot] af1d34a762 Bump actions/download-artifact from 4 to 5
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-06 17:01:52 +00:00
Alireza Ahmadi 69da810426 v1.3.1 2025-08-05 15:29:48 +02:00
Alireza Ahmadi 8f98050964 Merge pull request #703 from alireza0/dependabot/go_modules/github.com/gorilla/csrf-1.7.3
Bump github.com/gorilla/csrf from 1.7.3-0.20250123201450-9dd6af1f6d30 to 1.7.3
2025-08-05 13:07:32 +02:00
Alireza Ahmadi 1c14c1ce9c fix hy port mapping for clash sub 2025-08-05 12:53:15 +02:00
dependabot[bot] f2ccba3cd2 Bump github.com/gorilla/csrf
Bumps [github.com/gorilla/csrf](https://github.com/gorilla/csrf) from 1.7.3-0.20250123201450-9dd6af1f6d30 to 1.7.3.
- [Release notes](https://github.com/gorilla/csrf/releases)
- [Commits](https://github.com/gorilla/csrf/commits/v1.7.3)

---
updated-dependencies:
- dependency-name: github.com/gorilla/csrf
  dependency-version: 1.7.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-05 02:44:49 +00:00
Alireza Ahmadi 5ad8d61002 v1.3.0 2025-08-04 22:46:22 +02:00
Alireza Ahmadi f7e40023c4 Sing-box v1.12 2025-08-04 22:43:36 +02:00
Alireza Ahmadi 975150420c Merge pull request #702 from alireza0/sing-box-v.1.12
Sing box v1.12
2025-08-04 22:17:06 +02:00
Alireza Ahmadi 9c3db8cc2b Merge branch 'main' into sing-box-v.1.12 2025-08-04 22:16:56 +02:00
Alireza Ahmadi 55b6272204 support http,socks,mixed links 2025-08-04 19:32:24 +02:00
Alireza Ahmadi 371eb9ece8 v1.3.0-rc.5 2025-08-04 13:59:22 +02:00
Alireza Ahmadi e883a8e153 separate trackers, fix #695 2025-08-04 13:35:49 +02:00
Alireza Ahmadi f608f0bba0 v1.3.0-rc.4 2025-08-02 12:30:42 +02:00
Alireza Ahmadi 4c73fa6d58 sing-box v1.12.0-rc.4 2025-08-02 12:11:32 +02:00
Alireza Ahmadi 4068096fce update funding 2025-07-30 12:49:46 +02:00
83 changed files with 2830 additions and 1176 deletions
+1 -1
View File
@@ -1 +1 @@
github: alireza0
github: alireza0
+6 -6
View File
@@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
with:
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 20
- name: Install dependencies and build frontend
@@ -23,7 +23,7 @@ jobs:
npm install
npm run build
- name: Upload frontend build artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: frontend-dist
path: frontend/dist/
@@ -33,9 +33,9 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- name: Download frontend build artifact
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
name: frontend-dist
path: frontend_dist
@@ -58,7 +58,7 @@ jobs:
install: true
buildkitd-flags: --debug
- name: Cache Docker layers
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
+56 -47
View File
@@ -1,13 +1,25 @@
name: Release S-UI
on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- main
tags:
- "*"
workflow_dispatch:
paths:
- '.github/workflows/release.yml'
- 'frontend/**'
- '**.sh'
- '**.go'
- 'go.mod'
- 'go.sum'
- 's-ui.service'
jobs:
build:
build-linux:
strategy:
matrix:
platform:
@@ -18,41 +30,25 @@ jobs:
- armv5
- 386
- s390x
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
with:
submodules: recursive
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
cache: false
go-version-file: go.mod
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
sudo apt-get update
if [ "${{ matrix.platform }}" == "arm64" ]; then
sudo apt install gcc-aarch64-linux-gnu
elif [ "${{ matrix.platform }}" == "armv7" ]; then
sudo apt install gcc-arm-linux-gnueabihf
elif [ "${{ matrix.platform }}" == "armv6" ]; then
sudo apt install gcc-arm-linux-gnueabihf
elif [ "${{ matrix.platform }}" == "armv5" ]; then
sudo apt install gcc-arm-linux-gnueabi
elif [ "${{ matrix.platform }}" == "386" ]; then
sudo apt install gcc-i686-linux-gnu
elif [ "${{ matrix.platform }}" == "s390x" ]; then
sudo apt install gcc-s390x-linux-gnu
fi
- name: Build frontend
run: |
@@ -68,31 +64,34 @@ jobs:
export CGO_ENABLED=1
export GOOS=linux
export GOARCH=${{ matrix.platform }}
if [ "${{ matrix.platform }}" == "arm64" ]; then
export GOARCH=arm64
export CC=aarch64-linux-gnu-gcc
elif [ "${{ matrix.platform }}" == "armv7" ]; then
export GOARCH=arm
export GOARM=7
export CC=arm-linux-gnueabihf-gcc
elif [ "${{ matrix.platform }}" == "armv6" ]; then
export GOARCH=arm
export GOARM=6
export CC=arm-linux-gnueabihf-gcc
elif [ "${{ matrix.platform }}" == "armv5" ]; then
export GOARCH=arm
export GOARM=5
export CC=arm-linux-gnueabi-gcc
elif [ "${{ matrix.platform }}" == "386" ]; then
export GOARCH=386
export CC=i686-linux-gnu-gcc
elif [ "${{ matrix.platform }}" == "s390x" ]; then
export GOARCH=s390x
export CC=s390x-linux-gnu-gcc
fi
# Use Bootlin prebuilt cross-toolchains (musl 1.2.5 in stable series)
case "${{ matrix.platform }}" in
amd64) BOOTLIN_ARCH="x86-64" ;;
arm64) BOOTLIN_ARCH="aarch64" ;;
armv7) BOOTLIN_ARCH="armv7-eabihf"; export GOARCH=arm GOARM=7 ;;
armv6) BOOTLIN_ARCH="armv6-eabihf"; export GOARCH=arm GOARM=6 ;;
armv5) BOOTLIN_ARCH="armv5-eabi"; export GOARCH=arm GOARM=5 ;;
386) BOOTLIN_ARCH="x86-i686" ;;
s390x) BOOTLIN_ARCH="s390x-z13" ;;
esac
echo "Resolving Bootlin musl toolchain for arch=$BOOTLIN_ARCH (platform=${{ matrix.platform }})"
TARBALL_BASE="https://toolchains.bootlin.com/downloads/releases/toolchains/$BOOTLIN_ARCH/tarballs/"
TARBALL_URL=$(curl -fsSL "$TARBALL_BASE" | grep -oE "${BOOTLIN_ARCH}--musl--stable-[^\"]+\\.tar\\.xz" | sort -r | head -n1)
[ -z "$TARBALL_URL" ] && { echo "Failed to locate Bootlin musl toolchain for arch=$BOOTLIN_ARCH" >&2; exit 1; }
echo "Downloading: $TARBALL_URL"
cd /tmp
curl -fL -sS -o "$(basename "$TARBALL_URL")" "$TARBALL_BASE/$TARBALL_URL"
tar -xf "$(basename "$TARBALL_URL")"
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" | head -n1)
export PATH="$(realpath "$TOOLCHAIN_DIR")/bin:$PATH"
export CC=$(realpath "$(find "$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
[ -z "$CC" ] && { echo "No gcc.br_real found in $TOOLCHAIN_DIR/bin" >&2; exit 1; }
cd -
### Build s-ui
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
go build -ldflags="-w -s -linkmode external -extldflags '-static'" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
file sui
ldd sui || echo "Static binary confirmed"
mkdir s-ui
cp sui s-ui/
@@ -102,8 +101,18 @@ jobs:
- name: Package
run: tar -zcvf s-ui-linux-${{ matrix.platform }}.tar.gz s-ui
- name: Upload
- name: Upload files to Artifacts
uses: actions/upload-artifact@v7
with:
name: s-ui-linux-${{ matrix.platform }}
path: ./s-ui-linux-${{ matrix.platform }}.tar.gz
retention-days: 30
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
+177
View File
@@ -0,0 +1,177 @@
name: Build S-UI for Windows
on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- main
tags:
- "*"
paths:
- '.github/workflows/windows.yml'
- 'frontend/**'
- '**.go'
- 'go.mod'
- 'go.sum'
- 'windows/**'
jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
with:
submodules: recursive
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
cache: false
go-version-file: go.mod
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Install zip for Windows
shell: powershell
run: |
# Install Chocolatey if not available
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
}
# Install zip
choco install zip -y
- name: Build frontend
shell: bash
run: |
cd frontend
npm install
npm run build
cd ..
mv frontend/dist web/html
rm -fr frontend
- name: Build s-ui
shell: bash
run: |
export CGO_ENABLED=1
export GOOS=windows
export GOARCH=amd64
echo "Building for Windows amd64"
go version
### Build s-ui
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
file sui.exe
mkdir s-ui-windows
cp sui.exe s-ui-windows/
cp -r windows/* s-ui-windows/
- name: Package
shell: bash
run: |
zip -r "s-ui-windows-amd64.zip" s-ui-windows
- name: Upload files to Artifacts
uses: actions/upload-artifact@v7
with:
name: s-ui-windows-amd64
path: ./s-ui-windows-amd64.zip
retention-days: 30
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: s-ui-windows-amd64.zip
asset_name: s-ui-windows-amd64.zip
prerelease: true
overwrite: true
build-windows-arm64:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
with:
submodules: recursive
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
cache: false
go-version-file: go.mod
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Build frontend
run: |
cd frontend
npm install
npm run build
cd ..
mv frontend/dist web/html
rm -fr frontend
- name: Build s-ui for ARM64
run: |
export CGO_ENABLED=0
export GOOS=windows
export GOARCH=arm64
echo "Building for Windows ARM64 (32-bit)"
go version
go env GOOS GOARCH
### Build s-ui without CGO for ARM64
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
file sui.exe
mkdir s-ui-windows
cp sui.exe s-ui-windows/
cp -r windows/* s-ui-windows/
- name: Package ARM64
run: |
zip -r "s-ui-windows-arm64.zip" s-ui-windows
- name: Upload ARM64 files to Artifacts
uses: actions/upload-artifact@v7
with:
name: s-ui-windows-arm64
path: ./s-ui-windows-arm64.zip
retention-days: 30
- name: Upload ARM64 to Release
uses: svenstaro/upload-release-action@v2
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: s-ui-windows-arm64.zip
asset_name: s-ui-windows-arm64.zip
prerelease: true
overwrite: true
+8
View File
@@ -20,6 +20,14 @@ frontend/
*.log*
.cache
# Windows build artifacts
*.exe
*.zip
s-ui-windows/
sui-*.exe
sui-*.zip
windows/sui-*.exe
# Editor directories and files
.idea
.vscode
+276
View File
@@ -0,0 +1,276 @@
# Contributing to S-UI
Thank you for your interest in contributing to S-UI. This document explains how to set up a development environment, follow project conventions, and submit changes. Your contributions help make the **multi-inbound-per-user** approach and the rest of the project better for everyone.
## Table of Contents
- [Code of Conduct](#code-of-conduct)
- [Development Environment Setup](#development-environment-setup)
- [Coding Conventions and Style Guide](#coding-conventions-and-style-guide)
- [Testing](#testing)
- [Features That Need Help](#features-that-need-help)
- [Pull Request Process](#pull-request-process)
- [Adding This Guide in Your Repository](#adding-this-guide-in-your-repository)
- [Reporting Bugs and Requesting Features](#reporting-bugs-and-requesting-features)
---
## Code of Conduct
Please be respectful and constructive when interacting with maintainers and other contributors. This project is for personal learning and communication; use it responsibly and legally.
---
## Development Environment Setup
### Prerequisites
- **Go**: 1.25 or later (see `go.mod` for the exact version).
- **Git**: For cloning and submodules.
- **C compiler**: Required for CGO (e.g. `gcc`, `musl-dev` on Alpine).
- **Node.js** (optional): Only if you plan to work on or rebuild the frontend. The repo can be run with pre-built frontend assets.
### Clone and Submodules
```bash
git clone https://github.com/alireza0/s-ui
cd s-ui
git submodule update --init --recursive
```
The **frontend** lives in a submodule. If you only work on the backend, you can use the existing `web/html` contents or build the frontend once (see below).
### Backend-Only Development (quickest)
1. Build and run with the provided script (builds backend and runs with debug + local DB):
```bash
./runSUI.sh
```
This runs `./build.sh` then `SUI_DB_FOLDER="db" SUI_DEBUG=true ./sui`.
2. Or build manually:
```bash
./build.sh
SUI_DB_FOLDER=db SUI_DEBUG=true ./sui
```
Default panel: **http://localhost:2095/app/** (user: `admin`, password: `admin` — change in production).
### Full Stack (Backend + Frontend)
1. **Frontend** (separate repo in submodule):
```bash
cd frontend
npm install
npm run build
cd ..
```
2. **Replace web assets and build backend**:
```bash
mkdir -p web/html
rm -rf web/html/*
cp -R frontend/dist/* web/html/
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
```
3. Run:
```bash
SUI_DB_FOLDER=db SUI_DEBUG=true ./sui
```
### Build Tags
The backend is built with these tags for full functionality:
- `with_quic`, `with_grpc`, `with_utls`, `with_acme`, `with_gvisor`
Use the same tags when building locally if you need feature parity with releases.
### Environment Variables (development)
| Variable | Description | Example |
|----------------|--------------------------------|-----------|
| `SUI_DB_FOLDER`| Directory for SQLite DB files | `db` |
| `SUI_DEBUG` | Enable debug mode | `true` |
| `SUI_LOG_LEVEL`| Log level | `debug` |
| `SUI_BIN_FOLDER` | Directory for binaries | `bin` |
### Docker (optional)
```bash
git clone https://github.com/alireza0/s-ui
cd s-ui
git submodule update --init --recursive
docker build -t s-ui .
# or: docker compose up -d
```
---
## Coding Conventions and Style Guide
### General
- Write clear, maintainable code. Prefer small, focused functions and packages.
- Comment non-obvious logic and public APIs.
- Handle errors explicitly; avoid ignoring `err` unless intentional.
### Go Style
- Follow **standard Go style** and **[Effective Go](https://go.dev/doc/effective_go)**.
- Run **gofmt** (or **goimports**) before committing:
```bash
gofmt -w .
# or: goimports -w .
```
- Use **camelCase** for unexported names and **PascalCase** for exported names.
- Keep package names short and lowercase (e.g. `api`, `service`, `util`).
- Group imports: standard library, then third-party, then project imports (as in existing files).
### Project Structure Conventions
- **`api/`**: HTTP handlers and API routing (e.g. `apiHandler.go`, `apiV2Handler.go`).
- **`service/`**: Business logic and panel/core operations.
- **`database/model/`**: GORM models and DB entities.
- **`util/`**: Shared utilities (e.g. link/sub conversion, JSON).
- **`core/`**: sing-box integration and core runtime.
- **`sub/`**: Subscription (link/json) handling.
When adding new features, place code in the appropriate layer (handler → service → model/util) and avoid circular dependencies.
### Naming and Patterns
- Handlers: suffix `Handler` (e.g. `APIHandler`, `APIv2Handler`).
- Services: suffix `Service` or use package name (e.g. `ApiService`, `LinkService`).
- Models: clear struct names with JSON/gorm tags (see `database/model/`).
---
## Testing
### Current State
- The project does not yet have a formal test suite (no `*_test.go` files in the repo).
- CI currently focuses on **builds** (e.g. `release.yml`) rather than automated tests.
### What You Can Do Now
1. **Build verification**: Before submitting a PR, ensure the project builds:
```bash
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
```
2. **Manual testing**: Run with `./runSUI.sh`, test the changed area (panel, API, subscription, etc.).
3. **Future tests**: Contributions that add **unit tests** (e.g. for `util/`, `service/`, or API handlers) or **integration tests** are very welcome. Prefer the standard library `testing` package and table-driven tests where appropriate.
### Running the Linter (optional)
```bash
go vet ./...
# Optional: staticcheck, golangci-lint, etc.
```
---
## Features That Need Help
Community help is especially valuable in these areas. Check the [Issues](https://github.com/alireza0/s-ui/issues) for current tasks and ideas.
### High-Value Areas
- **Multi-inbound per user**: Core differentiator of S-UI; improvements to UX, docs, and robustness are welcome.
- **API (v1 and v2)**: Completeness, consistency, and documentation (see [API Documentation](https://github.com/alireza0/s-ui/wiki/API-Documentation)).
- **Subscription service**: Link conversion, JSON subscription, and info endpoints (`sub/`, `util/`).
- **Testing**: Adding unit and integration tests for critical paths.
- **Documentation**: User docs, API examples, and contribution docs (like this file).
- **Platform support**: macOS is experimental; Windows and Linux improvements are welcome (see `windows/` and `.github/workflows/`).
### How to Find Tasks
- **Good first issue**: Look for issues labeled `good first issue` or `help wanted`.
- **Feature requests**: [Feature request template](.github/ISSUE_TEMPLATE/feature_request.md).
- **Bugs**: [Bug report template](.github/ISSUE_TEMPLATE/bug_report.md).
If you want to work on a larger feature, open an issue first to discuss approach and avoid duplicate work.
---
## Pull Request Process
1. **Fork and branch**
- Fork the repository on GitHub.
- Create a branch from `main`: e.g. `git checkout -b fix/issue-123` or `feature/sub-improvements`.
2. **Make your changes**
- Follow the [Coding Conventions](#coding-conventions-and-style-guide).
- Run `gofmt` and ensure the project builds (see [Testing](#testing)).
- Keep commits focused and messages clear (e.g. "Fix link conversion for VMess", "Add tests for outJson").
3. **Push and open a PR**
- Push your branch and open a Pull Request against `main`.
- Use the PR description to explain:
- What problem or feature the PR addresses.
- What you changed and how to verify it.
- Reference any related issue (e.g. "Fixes #123").
4. **Review and CI**
- Maintainers will review your code. CI (e.g. build workflows) must pass.
- Address feedback by pushing new commits to the same branch.
5. **Merge**
- Once approved and CI is green, a maintainer will merge your PR. Thank you for contributing!
### PR Guidelines
- Prefer **small, reviewable PRs**. Split large features into logical steps.
- Avoid unrelated changes (e.g. formatting-only or refactors in a feature PR).
- Ensure your branch is up to date with `main` before submitting (rebase or merge as the project prefers).
---
## Adding This Guide in Your Repository
If you maintain a fork or your own repository and want the contribution guide to be visible and linked properly:
1. **Keep `CONTRIBUTING.md` in the repository root**
GitHub automatically discovers a file named `CONTRIBUTING.md` (or `CONTRIBUTING`) in the root. When someone opens a new issue or pull request, GitHub can show a link to it. The community profile also uses it for the “Contributing” section.
2. **Link from README**
Add a short line in your main `README.md` so new contributors see it when they land on the repo, for example:
```markdown
**Want to contribute?** See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding conventions, and the pull request process.
```
3. **Optional: GitHub “Contributing” link**
In the repository **Settings → General → Features**, ensure “Issues” (and optionally “Discussions”) are enabled. The link to `CONTRIBUTING.md` appears when users create a new issue or PR; no extra config is needed as long as the file is in the root.
4. **When forking**
If you fork S-UI, `CONTRIBUTING.md` is already in the repo. Update the clone URLs and repo names in this file if you want your forks contribution instructions to point to your own repository.
---
## Reporting Bugs and Requesting Features
- **Bugs**: Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md). Include version, OS, steps to reproduce, and expected vs actual behavior.
- **Features**: Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md). Describe the use case and, if possible, a proposed approach.
- **Questions**: Use the [question template](.github/ISSUE_TEMPLATE/question-template.md) or discussions if enabled.
---
Thank you for helping S-UI grow. Your contributions make it possible for more users to adopt S-UI in production and benefit from its multi-inbound-per-user design.
+2 -3
View File
@@ -3,7 +3,7 @@ WORKDIR /app
COPY frontend/ ./
RUN npm install && npm run build
FROM golang:1.24-alpine AS backend-builder
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app
ARG TARGETARCH
ENV CGO_ENABLED=1
@@ -33,8 +33,7 @@ FROM --platform=$TARGETPLATFORM alpine
LABEL org.opencontainers.image.authors="alireza7@gmail.com"
ENV TZ=Asia/Tehran
WORKDIR /app
RUN apk add --no-cache --update ca-certificates tzdata
RUN set -ex && apk add --no-cache --upgrade bash tzdata ca-certificates nftables
COPY --from=backend-builder /app/sui /app/
COPY entrypoint.sh /app/
VOLUME [ "s-ui" ]
ENTRYPOINT [ "./entrypoint.sh" ]
+2 -3
View File
@@ -1,4 +1,4 @@
FROM golang:1.24-alpine AS backend-builder
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app
ARG TARGETARCH
ENV CGO_ENABLED=1
@@ -29,8 +29,7 @@ FROM --platform=$TARGETPLATFORM alpine
LABEL org.opencontainers.image.authors="alireza7@gmail.com"
ENV TZ=Asia/Tehran
WORKDIR /app
RUN apk add --no-cache --update ca-certificates tzdata
RUN set -ex && apk add --no-cache --upgrade bash tzdata ca-certificates nftables
COPY --from=backend-builder /app/sui /app/
COPY entrypoint.sh /app/
VOLUME [ "s-ui" ]
ENTRYPOINT [ "./entrypoint.sh" ]
+30 -18
View File
@@ -11,9 +11,13 @@
**If you think this project is helpful to you, you may wish to give a**:star2:
**Want to contribute?** See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding conventions, testing, and the pull request process.
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/alireza7)
- USDT (TRC20): `TYTq73Gj6dJ67qe58JVPD9zpjW2cc9XgVz`
<a href="https://nowpayments.io/donation/alireza7" target="_blank" rel="noreferrer noopener">
<img src="https://nowpayments.io/images/embeds/donation-button-white.svg" alt="Crypto donation button by NOWPayments">
</a>
## Quick Overview
| Features | Enable? |
@@ -23,10 +27,17 @@
| Multi-Client/Inbound | :heavy_check_mark: |
| Advanced Traffic Routing Interface | :heavy_check_mark: |
| Client & Traffic & System Status | :heavy_check_mark: |
| Subscription Service (link/json + info)| :heavy_check_mark: |
| Subscription Link (link/json/clash + info)| :heavy_check_mark: |
| Dark/Light Theme | :heavy_check_mark: |
| API Interface | :heavy_check_mark: |
## Supported Platforms
| Platform | Architecture | Status |
|----------|--------------|---------|
| Linux | amd64, arm64, armv7, armv6, armv5, 386, s390x | ✅ Supported |
| Windows | amd64, 386, arm64 | ✅ Supported |
| macOS | amd64, arm64 | 🚧 Experimental |
## Screenshots
!["Main"](https://github.com/alireza0/s-ui-frontend/raw/main/media/main.png)
@@ -46,10 +57,17 @@
## Install & Upgrade to Latest Version
### Linux/macOS
```sh
bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui/master/install.sh)
```
### Windows
1. Download the latest Windows release from [GitHub Releases](https://github.com/alireza0/s-ui/releases/latest)
2. Extract the ZIP file
3. Run `install-windows.bat` as Administrator
4. Follow the installation wizard
## Install legacy Version
**Step 1:** To install your desired legacy version, add the version to the end of the installation command. e.g., ver `1.0.0`:
@@ -60,6 +78,7 @@ VERSION=1.0.0 && bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui
## Manual installation
### Linux/macOS
1. Get the latest version of S-UI based on your OS/Architecture from GitHub: [https://github.com/alireza0/s-ui/releases/latest](https://github.com/alireza0/s-ui/releases/latest)
2. **OPTIONAL** Get the latest version of `s-ui.sh` [https://raw.githubusercontent.com/alireza0/s-ui/master/s-ui.sh](https://raw.githubusercontent.com/alireza0/s-ui/master/s-ui.sh)
3. **OPTIONAL** Copy `s-ui.sh` to /usr/bin/ and run `chmod +x /usr/bin/s-ui`.
@@ -68,6 +87,14 @@ VERSION=1.0.0 && bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui
6. Enable autostart and start S-UI service using `systemctl enable s-ui --now`
7. Start sing-box service using `systemctl enable sing-box --now`
### Windows
1. Get the latest Windows version from GitHub: [https://github.com/alireza0/s-ui/releases/latest](https://github.com/alireza0/s-ui/releases/latest)
2. Download the appropriate Windows package (e.g., `s-ui-windows-amd64.zip`)
3. Extract the ZIP file to a directory of your choice
4. Run `install-windows.bat` as Administrator
5. Follow the installation wizard
6. Access the panel at http://localhost:2095/app
## Uninstall S-UI
```sh
@@ -111,7 +138,7 @@ docker compose up -d
mkdir s-ui && cd s-ui
docker run -itd \
-p 2095:2095 -p 2096:2096 -p 443:443 -p 80:80 \
-v $PWD/db/:/usr/local/s-ui/db/ \
-v $PWD/db/:/app/db/ \
-v $PWD/cert/:/root/cert/ \
--name s-ui --restart=unless-stopped \
alireza7/s-ui:latest
@@ -194,21 +221,6 @@ To run backend (from root folder of repository):
- HTTPS for secure access to the web panel and subscription service (self-provided domain + SSL certificate)
- Dark/Light theme
## Recommended OS
- Ubuntu 20.04+
- Debian 11+
- CentOS 8+
- Fedora 36+
- Arch Linux
- Parch Linux
- Manjaro
- Armbian
- AlmaLinux 9+
- Rocky Linux 9+
- Oracle Linux 8+
- OpenSUSE Tubleweed
## Environment Variables
<details>
+9 -2
View File
@@ -1,9 +1,10 @@
package api
import (
"s-ui/util/common"
"strings"
"github.com/alireza0/s-ui/util/common"
"github.com/gin-gonic/gin"
)
@@ -47,6 +48,8 @@ func (a *APIHandler) postHandler(c *gin.Context) {
a.ApiService.RestartSb(c)
case "linkConvert":
a.ApiService.LinkConvert(c)
case "subConvert":
a.ApiService.SubConvert(c)
case "importdb":
a.ApiService.ImportDb(c)
case "addToken":
@@ -68,7 +71,7 @@ func (a *APIHandler) getHandler(c *gin.Context) {
a.ApiService.Logout(c)
case "load":
a.ApiService.LoadData(c)
case "inbounds", "outbounds", "endpoints", "tls", "clients", "config":
case "inbounds", "outbounds", "endpoints", "services", "tls", "clients", "config":
err := a.ApiService.LoadPartialData(c, []string{action})
if err != nil {
jsonMsg(c, action, err)
@@ -94,6 +97,10 @@ func (a *APIHandler) getHandler(c *gin.Context) {
a.ApiService.GetDb(c)
case "tokens":
a.ApiService.GetTokens(c)
case "singbox-config":
a.ApiService.GetSingboxConfig(c)
case "checkOutbound":
a.ApiService.GetCheckOutbound(c)
default:
jsonMsg(c, "failed", common.NewError("unknown action: ", action))
}
+36 -6
View File
@@ -2,14 +2,14 @@ package api
import (
"encoding/json"
"s-ui/database"
"s-ui/logger"
"s-ui/service"
"s-ui/util"
"strconv"
"strings"
"time"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
"github.com/alireza0/s-ui/util"
"github.com/gin-gonic/gin"
)
@@ -86,7 +86,11 @@ func (a *ApiService) getData(c *gin.Context) (interface{}, error) {
if err != nil {
return "", err
}
subURI, err := a.SettingService.GetFinalSubURI(strings.Split(c.Request.Host, ":")[0])
subURI, err := a.SettingService.GetFinalSubURI(getHostname(c))
if err != nil {
return "", err
}
trafficAge, err := a.SettingService.GetTrafficAge()
if err != nil {
return "", err
}
@@ -98,6 +102,7 @@ func (a *ApiService) getData(c *gin.Context) (interface{}, error) {
data["endpoints"] = endpoints
data["services"] = services
data["subURI"] = subURI
data["enableTraffic"] = trafficAge > 0
data["onlines"] = onlines
} else {
data["onlines"] = onlines
@@ -325,6 +330,12 @@ func (a *ApiService) LinkConvert(c *gin.Context) {
jsonObj(c, result, err)
}
func (a *ApiService) SubConvert(c *gin.Context) {
link := c.Request.FormValue("link")
result, err := util.GetExternalSub(link)
jsonObj(c, result, err)
}
func (a *ApiService) ImportDb(c *gin.Context) {
file, _, err := c.Request.FormFile("db")
if err != nil {
@@ -373,3 +384,22 @@ func (a *ApiService) DeleteToken(c *gin.Context) {
err := a.UserService.DeleteToken(tokenId)
jsonMsg(c, "", err)
}
func (a *ApiService) GetSingboxConfig(c *gin.Context) {
rawConfig, err := a.ConfigService.GetConfig("")
if err != nil {
c.Status(400)
c.Writer.WriteString(err.Error())
return
}
c.Header("Content-Type", "application/json")
c.Header("Content-Disposition", "attachment; filename=config_"+time.Now().Format("20060102-150405")+".json")
c.Writer.Write(*rawConfig)
}
func (a *ApiService) GetCheckOutbound(c *gin.Context) {
tag := c.Query("tag")
link := c.Query("link")
result := a.ConfigService.CheckOutbound(tag, link)
jsonObj(c, result, nil)
}
+8 -3
View File
@@ -2,10 +2,11 @@ package api
import (
"encoding/json"
"s-ui/logger"
"s-ui/util/common"
"time"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
"github.com/gin-gonic/gin"
)
@@ -48,6 +49,8 @@ func (a *APIv2Handler) postHandler(c *gin.Context) {
a.ApiService.RestartSb(c)
case "linkConvert":
a.ApiService.LinkConvert(c)
case "subConvert":
a.ApiService.SubConvert(c)
case "importdb":
a.ApiService.ImportDb(c)
default:
@@ -61,7 +64,7 @@ func (a *APIv2Handler) getHandler(c *gin.Context) {
switch action {
case "load":
a.ApiService.LoadData(c)
case "inbounds", "outbounds", "endpoints", "tls", "clients", "config":
case "inbounds", "outbounds", "endpoints", "services", "tls", "clients", "config":
err := a.ApiService.LoadPartialData(c, []string{action})
if err != nil {
jsonMsg(c, action, err)
@@ -85,6 +88,8 @@ func (a *APIv2Handler) getHandler(c *gin.Context) {
a.ApiService.GetKeypairs(c)
case "getdb":
a.ApiService.GetDb(c)
case "checkOutbound":
a.ApiService.GetCheckOutbound(c)
default:
jsonMsg(c, "failed", common.NewError("unknown action: ", action))
}
+2 -1
View File
@@ -2,7 +2,8 @@ package api
import (
"encoding/gob"
"s-ui/database/model"
"github.com/alireza0/s-ui/database/model"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
+6 -2
View File
@@ -3,9 +3,10 @@ package api
import (
"net"
"net/http"
"s-ui/logger"
"strings"
"github.com/alireza0/s-ui/logger"
"github.com/gin-gonic/gin"
)
@@ -29,8 +30,11 @@ func getRemoteIp(c *gin.Context) string {
func getHostname(c *gin.Context) string {
host := c.Request.Host
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
if strings.Contains(host, ":") {
host, _, _ = net.SplitHostPort(c.Request.Host)
if strings.Contains(host, ":") {
host = "[" + host + "]"
}
}
return host
}
+10 -9
View File
@@ -2,14 +2,15 @@ package app
import (
"log"
"s-ui/config"
"s-ui/core"
"s-ui/cronjob"
"s-ui/database"
"s-ui/logger"
"s-ui/service"
"s-ui/sub"
"s-ui/web"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/core"
"github.com/alireza0/s-ui/cronjob"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
"github.com/alireza0/s-ui/sub"
"github.com/alireza0/s-ui/web"
"github.com/op/go-logging"
)
@@ -78,7 +79,7 @@ func (a *APP) Start() error {
return err
}
err = a.configService.StartCore("")
err = a.configService.StartCore()
if err != nil {
logger.Error(err)
}
+4 -3
View File
@@ -2,9 +2,10 @@ package cmd
import (
"fmt"
"s-ui/config"
"s-ui/database"
"s-ui/service"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/service"
)
func resetAdmin() {
+3 -2
View File
@@ -5,8 +5,9 @@ import (
"fmt"
"os"
"runtime/debug"
"s-ui/cmd/migration"
"s-ui/config"
"github.com/alireza0/s-ui/cmd/migration"
"github.com/alireza0/s-ui/config"
)
func ParseCmd() {
+2 -1
View File
@@ -3,9 +3,10 @@ package migration
import (
"encoding/json"
"fmt"
"s-ui/database/model"
"strings"
"github.com/alireza0/s-ui/database/model"
"gorm.io/gorm"
)
+2 -1
View File
@@ -5,7 +5,8 @@ import (
"errors"
"os"
"path/filepath"
"s-ui/database/model"
"github.com/alireza0/s-ui/database/model"
"gorm.io/gorm"
)
+2 -1
View File
@@ -3,10 +3,11 @@ package migration
import (
"encoding/json"
"net/url"
"s-ui/database/model"
"strconv"
"strings"
"github.com/alireza0/s-ui/database/model"
"gorm.io/gorm"
)
+2 -1
View File
@@ -4,7 +4,8 @@ import (
"fmt"
"log"
"os"
"s-ui/config"
"github.com/alireza0/s-ui/config"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
+57 -11
View File
@@ -4,10 +4,13 @@ import (
"fmt"
"io"
"net/http"
"s-ui/config"
"s-ui/database"
"s-ui/service"
"strings"
"sync"
"time"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/service"
"github.com/shirou/gopsutil/v4/net"
)
@@ -109,6 +112,54 @@ func showSetting() {
}
}
func getPublicIP() string {
apis := []string{
"https://api64.ipify.org",
"https://ip.sb",
"https://icanhazip.com",
"https://ipinfo.io/ip",
"https://checkip.amazonaws.com",
}
type result struct {
ip string
err error
}
ch := make(chan result, len(apis))
var wg sync.WaitGroup
client := &http.Client{Timeout: 3 * time.Second}
for _, api := range apis {
wg.Add(1)
go func(url string) {
defer wg.Done()
resp, err := client.Get(url)
if err != nil {
ch <- result{"", err}
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
ch <- result{"", err}
return
}
ch <- result{string(body), nil}
}(api)
}
go func() {
wg.Wait()
close(ch)
}()
for res := range ch {
if res.err == nil && res.ip != "" {
return strings.TrimSpace(res.ip)
}
}
return ""
}
func getPanelURI() {
err := database.InitDB(config.GetDBPath())
if err != nil {
@@ -145,7 +196,6 @@ func getPanelURI() {
return
}
fmt.Println("Local address:")
// get ip address
netInterfaces, _ := net.Interfaces()
for i := 0; i < len(netInterfaces); i++ {
if len(netInterfaces[i].Flags) > 2 && netInterfaces[i].Flags[0] == "up" && netInterfaces[i].Flags[1] != "loopback" {
@@ -160,12 +210,8 @@ func getPanelURI() {
}
}
}
resp, err := http.Get("https://api.ipify.org?format=text")
if err == nil {
defer resp.Body.Close()
ip, err := io.ReadAll(resp.Body)
if err == nil {
fmt.Printf("\nGlobal address:\n%s%s%s%s\n", Proto, ip, PortText, BasePath)
}
pubIP := getPublicIP()
if pubIP != "" {
fmt.Printf("\nGlobal address:\n%s%s%s\n", Proto, pubIP, PortText+BasePath)
}
}
+6 -1
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
)
@@ -51,9 +52,13 @@ func GetDBFolderPath() string {
if dbFolderPath == "" {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
// Cross-platform fallback path
if runtime.GOOS == "windows" {
return "C:\\Program Files\\s-ui\\db"
}
return "/usr/local/s-ui/db"
}
dbFolderPath = dir + "/db"
dbFolderPath = filepath.Join(dir, "db")
}
return dbFolderPath
}
+1 -1
View File
@@ -1 +1 @@
1.3.0-rc.3
1.3.11
+16 -5
View File
@@ -5,9 +5,10 @@ import (
"fmt"
"io"
"os"
"s-ui/util/common"
"time"
"github.com/alireza0/s-ui/util/common"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/adapter/endpoint"
"github.com/sagernet/sing-box/adapter/inbound"
@@ -49,6 +50,7 @@ type Box struct {
connection *route.ConnectionManager
router *route.Router
internalService []adapter.LifecycleService
statsTracker *StatsTracker
connTracker *ConnTracker
done chan struct{}
}
@@ -302,15 +304,15 @@ func NewBox(options Options) (*Box, error) {
return nil, common.NewError("initialize service["+F.ToString(i)+"]"+tag, err)
}
}
outboundManager.Initialize(sbCommon.Must1(
direct.NewOutbound(
outboundManager.Initialize(func() (adapter.Outbound, error) {
return direct.NewOutbound(
ctx,
router,
logFactory.NewLogger("outbound/direct"),
"direct",
option.DirectOutboundOptions{},
),
))
)
})
dnsTransportManager.Initialize(sbCommon.Must1(
local.NewTransport(
ctx,
@@ -324,6 +326,10 @@ func NewBox(options Options) (*Box, error) {
return nil, common.NewError("initialize platform interface", err)
}
}
if statsTracker == nil {
statsTracker = NewStatsTracker()
}
router.AppendTracker(statsTracker)
if connTracker == nil {
connTracker = NewConnTracker()
}
@@ -387,6 +393,7 @@ func NewBox(options Options) (*Box, error) {
logFactory: logFactory,
logger: logFactory.Logger(),
internalService: internalServices,
statsTracker: statsTracker,
connTracker: connTracker,
done: make(chan struct{}),
}, nil
@@ -530,6 +537,10 @@ func (s *Box) Endpoint() adapter.EndpointManager {
return s.endpoint
}
func (s *Box) StatsTracker() *StatsTracker {
return s.statsTracker
}
func (s *Box) ConnTracker() *ConnTracker {
return s.connTracker
}
-258
View File
@@ -1,258 +0,0 @@
package core
import (
"context"
"net"
"s-ui/database/model"
"sync"
"time"
"github.com/gofrs/uuid/v5"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing/common/atomic"
"github.com/sagernet/sing/common/bufio"
"github.com/sagernet/sing/common/network"
)
type Counter struct {
read *atomic.Int64
write *atomic.Int64
}
type ConnectionInfo struct {
ID string
Conn net.Conn
PacketConn network.PacketConn
Inbound string
User string
CreatedAt time.Time
Type string // "tcp" or "udp"
}
type ConnTracker struct {
access sync.Mutex
createdAt time.Time
inbounds map[string]Counter
outbounds map[string]Counter
users map[string]Counter
connections map[string]*ConnectionInfo
}
func NewConnTracker() *ConnTracker {
return &ConnTracker{
createdAt: time.Now(),
inbounds: make(map[string]Counter),
outbounds: make(map[string]Counter),
users: make(map[string]Counter),
connections: make(map[string]*ConnectionInfo),
}
}
func (c *ConnTracker) getReadCounters(inbound string, outbound string, user string) ([]*atomic.Int64, []*atomic.Int64) {
var readCounter []*atomic.Int64
var writeCounter []*atomic.Int64
c.access.Lock()
if inbound != "" {
readCounter = append(readCounter, c.loadOrCreateCounter(&c.inbounds, inbound).read)
writeCounter = append(writeCounter, c.inbounds[inbound].write)
}
if outbound != "" {
readCounter = append(readCounter, c.loadOrCreateCounter(&c.outbounds, outbound).read)
writeCounter = append(writeCounter, c.outbounds[outbound].write)
}
if user != "" {
readCounter = append(readCounter, c.loadOrCreateCounter(&c.users, user).read)
writeCounter = append(writeCounter, c.users[user].write)
}
c.access.Unlock()
return readCounter, writeCounter
}
func (c *ConnTracker) loadOrCreateCounter(obj *map[string]Counter, name string) Counter {
counter, loaded := (*obj)[name]
if loaded {
return counter
}
counter = Counter{read: &atomic.Int64{}, write: &atomic.Int64{}}
(*obj)[name] = counter
return counter
}
func (c *ConnTracker) generateConnectionID() string {
return uuid.Must(uuid.NewV4()).String()
}
func (c *ConnTracker) trackConnection(connID string, connInfo *ConnectionInfo) {
c.access.Lock()
defer c.access.Unlock()
c.connections[connID] = connInfo
}
func (c *ConnTracker) untrackConnection(connID string) {
c.access.Lock()
defer c.access.Unlock()
delete(c.connections, connID)
}
func (c *ConnTracker) createWrappedConn(conn net.Conn, connID string) net.Conn {
return &wrappedConn{
Conn: conn,
tracker: c,
connID: connID,
}
}
func (c *ConnTracker) createWrappedPacketConn(conn network.PacketConn, connID string) network.PacketConn {
return &wrappedPacketConn{
PacketConn: conn,
tracker: c,
connID: connID,
}
}
func (c *ConnTracker) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) net.Conn {
readCounter, writeCounter := c.getReadCounters(metadata.Inbound, matchOutbound.Tag(), metadata.User)
connID := c.generateConnectionID()
connInfo := &ConnectionInfo{
ID: connID,
Conn: conn,
Inbound: metadata.Inbound,
User: metadata.User,
CreatedAt: time.Now(),
Type: "tcp",
}
c.trackConnection(connID, connInfo)
wrappedConn := c.createWrappedConn(conn, connID)
return bufio.NewInt64CounterConn(wrappedConn, readCounter, writeCounter)
}
func (c *ConnTracker) RoutedPacketConnection(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) network.PacketConn {
readCounter, writeCounter := c.getReadCounters(metadata.Inbound, matchOutbound.Tag(), metadata.User)
connID := c.generateConnectionID()
connInfo := &ConnectionInfo{
ID: connID,
PacketConn: conn,
Inbound: metadata.Inbound,
User: metadata.User,
CreatedAt: time.Now(),
Type: "udp",
}
c.trackConnection(connID, connInfo)
wrappedConn := c.createWrappedPacketConn(conn, connID)
return bufio.NewInt64CounterPacketConn(wrappedConn, readCounter, writeCounter)
}
func (c *ConnTracker) ForceCloseConn(inbound, user string) int {
c.access.Lock()
defer c.access.Unlock()
closedCount := 0
for connID, connInfo := range c.connections {
if connInfo.Inbound == inbound && connInfo.User == user {
if connInfo.Conn != nil {
connInfo.Conn.Close()
}
if connInfo.PacketConn != nil {
connInfo.PacketConn.Close()
}
delete(c.connections, connID)
closedCount++
}
}
return closedCount
}
func (c *ConnTracker) CloseConnByInbound(inbound string) int {
c.access.Lock()
defer c.access.Unlock()
closedCount := 0
for connID, connInfo := range c.connections {
if connInfo.Inbound == inbound {
if connInfo.Conn != nil {
connInfo.Conn.Close()
}
if connInfo.PacketConn != nil {
connInfo.PacketConn.Close()
}
delete(c.connections, connID)
closedCount++
}
}
return closedCount
}
func (c *ConnTracker) GetStats() *[]model.Stats {
c.access.Lock()
defer c.access.Unlock()
dt := time.Now().Unix()
s := []model.Stats{}
for inbound, counter := range c.inbounds {
down := counter.write.Swap(0)
up := counter.read.Swap(0)
if down > 0 || up > 0 {
s = append(s, model.Stats{
DateTime: dt,
Resource: "inbound",
Tag: inbound,
Direction: false,
Traffic: down,
}, model.Stats{
DateTime: dt,
Resource: "inbound",
Tag: inbound,
Direction: true,
Traffic: up,
})
}
}
for outbound, counter := range c.outbounds {
down := counter.write.Swap(0)
up := counter.read.Swap(0)
if down > 0 || up > 0 {
s = append(s, model.Stats{
DateTime: dt,
Resource: "outbound",
Tag: outbound,
Direction: false,
Traffic: down,
}, model.Stats{
DateTime: dt,
Resource: "outbound",
Tag: outbound,
Direction: true,
Traffic: up,
})
}
}
for user, counter := range c.users {
down := counter.write.Swap(0)
up := counter.read.Swap(0)
if down > 0 || up > 0 {
s = append(s, model.Stats{
DateTime: dt,
Resource: "user",
Tag: user,
Direction: false,
Traffic: down,
}, model.Stats{
DateTime: dt,
Resource: "user",
Tag: user,
Direction: true,
Traffic: up,
})
}
}
return &s
}
+2 -2
View File
@@ -1,8 +1,8 @@
package core
import (
"s-ui/logger"
"s-ui/util/common"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/option"
+2 -1
View File
@@ -4,9 +4,10 @@ import (
"context"
"io"
"os"
suiLog "s-ui/logger"
"time"
suiLog "github.com/alireza0/s-ui/logger"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing/common"
F "github.com/sagernet/sing/common/format"
+7 -5
View File
@@ -2,7 +2,8 @@ package core
import (
"context"
"s-ui/logger"
"github.com/alireza0/s-ui/logger"
sb "github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/adapter"
@@ -22,6 +23,7 @@ var (
service_manager adapter.ServiceManager
endpoint_manager adapter.EndpointManager
router adapter.Router
statsTracker *StatsTracker
connTracker *ConnTracker
factory log.Factory
)
@@ -80,11 +82,11 @@ func (c *Core) Start(sbConfig []byte) error {
}
func (c *Core) Stop() error {
if c.isRunning {
c.isRunning = false
return c.instance.Close()
c.isRunning = false
if c.instance != nil {
return nil
}
return nil
return c.instance.Close()
}
func (c *Core) IsRunning() bool {
+40
View File
@@ -0,0 +1,40 @@
package core
import (
"context"
"time"
urltest "github.com/sagernet/sing-box/common/urltest"
)
const checkTimeout = 15 * time.Second
type CheckOutboundResult struct {
OK bool
Delay uint16
Error string
}
func CheckOutbound(ctx context.Context, tag string, link string) (result CheckOutboundResult) {
if outbound_manager == nil {
result.Error = "core not running"
return result
}
ob, ok := outbound_manager.Outbound(tag)
if !ok {
result.Error = "outbound not found"
return result
}
ctx, cancel := context.WithTimeout(ctx, checkTimeout)
defer cancel()
delay, err := urltest.URLTest(ctx, link, ob)
if err != nil {
result.Error = err.Error()
return result
}
result.OK = true
result.Delay = delay
return result
}
+136
View File
@@ -0,0 +1,136 @@
package core
import (
"context"
"net"
"sync"
"github.com/gofrs/uuid/v5"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing/common/network"
)
type ConnectionInfo struct {
ID string
Conn net.Conn
PacketConn network.PacketConn
Inbound string
Type string // "tcp" or "udp"
}
type ConnTracker struct {
access sync.Mutex
connections map[string]*ConnectionInfo
}
func NewConnTracker() *ConnTracker {
return &ConnTracker{
connections: make(map[string]*ConnectionInfo),
}
}
func (c *ConnTracker) generateConnectionID() string {
return uuid.Must(uuid.NewV4()).String()
}
func (c *ConnTracker) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) net.Conn {
connID := c.generateConnectionID()
connInfo := &ConnectionInfo{
ID: connID,
Conn: conn,
Inbound: metadata.Inbound,
Type: "tcp",
}
c.trackConnection(connID, connInfo)
return c.createWrappedConn(conn, connID)
}
func (c *ConnTracker) RoutedPacketConnection(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) network.PacketConn {
connID := c.generateConnectionID()
connInfo := &ConnectionInfo{
ID: connID,
PacketConn: conn,
Inbound: metadata.Inbound,
Type: "udp",
}
c.trackConnection(connID, connInfo)
return c.createWrappedPacketConn(conn, connID)
}
func (c *ConnTracker) CloseConnByInbound(inbound string) int {
c.access.Lock()
defer c.access.Unlock()
closedCount := 0
for connID, connInfo := range c.connections {
if connInfo.Inbound == inbound {
if connInfo.Conn != nil {
connInfo.Conn.Close()
}
if connInfo.PacketConn != nil {
connInfo.PacketConn.Close()
}
delete(c.connections, connID)
closedCount++
}
}
return closedCount
}
func (c *ConnTracker) trackConnection(connID string, connInfo *ConnectionInfo) {
c.access.Lock()
defer c.access.Unlock()
c.connections[connID] = connInfo
}
func (c *ConnTracker) untrackConnection(connID string) {
c.access.Lock()
defer c.access.Unlock()
delete(c.connections, connID)
}
func (c *ConnTracker) createWrappedConn(conn net.Conn, connID string) *wrappedConn {
return &wrappedConn{
Conn: conn,
connID: connID,
}
}
func (c *ConnTracker) createWrappedPacketConn(conn network.PacketConn, connID string) *wrappedPacketConn {
return &wrappedPacketConn{
PacketConn: conn,
connID: connID,
}
}
type wrappedConn struct {
net.Conn
connID string
}
func (w *wrappedConn) Close() error {
connTracker.untrackConnection(w.connID)
return w.Conn.Close()
}
func (w *wrappedConn) Upstream() any {
return w.Conn
}
type wrappedPacketConn struct {
network.PacketConn
connID string
}
func (w *wrappedPacketConn) Close() error {
connTracker.untrackConnection(w.connID)
return w.PacketConn.Close()
}
func (w *wrappedPacketConn) Upstream() any {
return w.PacketConn
}
+145
View File
@@ -0,0 +1,145 @@
package core
import (
"context"
"net"
"sync"
"time"
"github.com/alireza0/s-ui/database/model"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing/common/atomic"
"github.com/sagernet/sing/common/bufio"
"github.com/sagernet/sing/common/network"
)
type Counter struct {
read *atomic.Int64
write *atomic.Int64
}
type StatsTracker struct {
access sync.Mutex
inbounds map[string]Counter
outbounds map[string]Counter
users map[string]Counter
}
func NewStatsTracker() *StatsTracker {
return &StatsTracker{
inbounds: make(map[string]Counter),
outbounds: make(map[string]Counter),
users: make(map[string]Counter),
}
}
func (c *StatsTracker) getReadCounters(inbound string, outbound string, user string) ([]*atomic.Int64, []*atomic.Int64) {
var readCounter []*atomic.Int64
var writeCounter []*atomic.Int64
c.access.Lock()
defer c.access.Unlock()
if inbound != "" {
readCounter = append(readCounter, c.loadOrCreateCounter(&c.inbounds, inbound).read)
writeCounter = append(writeCounter, c.inbounds[inbound].write)
}
if outbound != "" {
readCounter = append(readCounter, c.loadOrCreateCounter(&c.outbounds, outbound).read)
writeCounter = append(writeCounter, c.outbounds[outbound].write)
}
if user != "" {
readCounter = append(readCounter, c.loadOrCreateCounter(&c.users, user).read)
writeCounter = append(writeCounter, c.users[user].write)
}
return readCounter, writeCounter
}
func (c *StatsTracker) loadOrCreateCounter(obj *map[string]Counter, name string) Counter {
counter, loaded := (*obj)[name]
if loaded {
return counter
}
counter = Counter{read: &atomic.Int64{}, write: &atomic.Int64{}}
(*obj)[name] = counter
return counter
}
func (c *StatsTracker) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) net.Conn {
readCounter, writeCounter := c.getReadCounters(metadata.Inbound, matchOutbound.Tag(), metadata.User)
return bufio.NewInt64CounterConn(conn, readCounter, writeCounter)
}
func (c *StatsTracker) RoutedPacketConnection(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) network.PacketConn {
readCounter, writeCounter := c.getReadCounters(metadata.Inbound, matchOutbound.Tag(), metadata.User)
return bufio.NewInt64CounterPacketConn(conn, readCounter, nil, writeCounter, nil)
}
func (c *StatsTracker) GetStats() *[]model.Stats {
c.access.Lock()
defer c.access.Unlock()
dt := time.Now().Unix()
s := []model.Stats{}
for inbound, counter := range c.inbounds {
down := counter.write.Swap(0)
up := counter.read.Swap(0)
if down > 0 || up > 0 {
s = append(s, model.Stats{
DateTime: dt,
Resource: "inbound",
Tag: inbound,
Direction: false,
Traffic: down,
}, model.Stats{
DateTime: dt,
Resource: "inbound",
Tag: inbound,
Direction: true,
Traffic: up,
})
}
}
for outbound, counter := range c.outbounds {
down := counter.write.Swap(0)
up := counter.read.Swap(0)
if down > 0 || up > 0 {
s = append(s, model.Stats{
DateTime: dt,
Resource: "outbound",
Tag: outbound,
Direction: false,
Traffic: down,
}, model.Stats{
DateTime: dt,
Resource: "outbound",
Tag: outbound,
Direction: true,
Traffic: up,
})
}
}
for user, counter := range c.users {
down := counter.write.Swap(0)
up := counter.read.Swap(0)
if down > 0 || up > 0 {
s = append(s, model.Stats{
DateTime: dt,
Resource: "user",
Tag: user,
Direction: false,
Traffic: down,
}, model.Stats{
DateTime: dt,
Resource: "user",
Tag: user,
Direction: true,
Traffic: up,
})
}
}
return &s
}
-29
View File
@@ -1,29 +0,0 @@
package core
import (
"net"
"github.com/sagernet/sing/common/network"
)
type wrappedConn struct {
net.Conn
tracker *ConnTracker
connID string
}
func (w *wrappedConn) Close() error {
w.tracker.untrackConnection(w.connID)
return w.Conn.Close()
}
type wrappedPacketConn struct {
network.PacketConn
tracker *ConnTracker
connID string
}
func (w *wrappedPacketConn) Close() error {
w.tracker.untrackConnection(w.connID)
return w.PacketConn.Close()
}
+2 -2
View File
@@ -1,7 +1,7 @@
package cronjob
import (
"s-ui/service"
"github.com/alireza0/s-ui/service"
)
type CheckCoreJob struct {
@@ -13,5 +13,5 @@ func NewCheckCoreJob() *CheckCoreJob {
}
func (s *CheckCoreJob) Run() {
s.ConfigService.StartCore("")
s.ConfigService.StartCore()
}
+4 -2
View File
@@ -20,11 +20,13 @@ func (c *CronJob) Start(loc *time.Location, trafficAge int) error {
go func() {
// Start stats job
c.cron.AddJob("@every 10s", NewStatsJob())
c.cron.AddJob("@every 10s", NewStatsJob(trafficAge > 0))
// Start expiry job
c.cron.AddJob("@every 1m", NewDepleteJob())
// Start deleting old stats
c.cron.AddJob("@daily", NewDelStatsJob(trafficAge))
if trafficAge > 0 {
c.cron.AddJob("@daily", NewDelStatsJob(trafficAge))
}
// Start core if it is not running
c.cron.AddJob("@every 5s", NewCheckCoreJob())
}()
+2 -2
View File
@@ -1,8 +1,8 @@
package cronjob
import (
"s-ui/logger"
"s-ui/service"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
)
type DelStatsJob struct {
+3 -3
View File
@@ -1,9 +1,9 @@
package cronjob
import (
"s-ui/database"
"s-ui/logger"
"s-ui/service"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
)
type DepleteJob struct {
+8 -5
View File
@@ -1,20 +1,23 @@
package cronjob
import (
"s-ui/logger"
"s-ui/service"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
)
type StatsJob struct {
service.StatsService
enableTraffic bool
}
func NewStatsJob() *StatsJob {
return &StatsJob{}
func NewStatsJob(saveTraffic bool) *StatsJob {
return &StatsJob{
enableTraffic: saveTraffic,
}
}
func (s *StatsJob) Run() {
err := s.StatsService.SaveStats()
err := s.StatsService.SaveStats(s.enableTraffic)
if err != nil {
logger.Warning("Get stats failed: ", err)
return
+12 -6
View File
@@ -7,15 +7,17 @@ import (
"mime/multipart"
"os"
"path/filepath"
"s-ui/cmd/migration"
"s-ui/config"
"s-ui/database/model"
"s-ui/logger"
"s-ui/util/common"
"runtime"
"strings"
"syscall"
"time"
"github.com/alireza0/s-ui/cmd/migration"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@@ -287,7 +289,11 @@ func SendSighup() error {
// Send SIGHUP to the current process
go func() {
time.Sleep(3 * time.Second)
err := process.Signal(syscall.SIGHUP)
if runtime.GOOS == "windows" {
err = process.Kill()
} else {
err = process.Signal(syscall.SIGHUP)
}
if err != nil {
logger.Error("send signal SIGHUP failed:", err)
}
+10 -3
View File
@@ -4,8 +4,10 @@ import (
"encoding/json"
"os"
"path"
"s-ui/config"
"s-ui/database/model"
"strings"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database/model"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -48,7 +50,12 @@ func OpenDB(dbPath string) error {
c := &gorm.Config{
Logger: gormLogger,
}
db, err = gorm.Open(sqlite.Open(dbPath), c)
sep := "?"
if strings.Contains(dbPath, "?") {
sep = "&"
}
dsn := dbPath + sep + "_busy_timeout=10000"
db, err = gorm.Open(sqlite.Open(dsn), c)
if config.IsDebug() {
db = db.Debug()
+6 -2
View File
@@ -1,4 +1,8 @@
#!/bin/sh
./sui migrate
./sui
DB_PATH="${SUI_DB_FOLDER:-/app/db}/s-ui.db"
if [ -f "$DB_PATH" ]; then
./sui migrate
fi
exec ./sui
+45 -42
View File
@@ -1,46 +1,47 @@
module s-ui
module github.com/alireza0/s-ui
go 1.24.5
go 1.25.7
require (
github.com/gin-contrib/gzip v1.2.3
github.com/gin-contrib/gzip v1.2.5
github.com/gin-contrib/sessions v1.0.4
github.com/gin-gonic/gin v1.10.1
github.com/google/uuid v1.6.0
github.com/gin-gonic/gin v1.11.0
github.com/gofrs/uuid/v5 v5.4.0
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/robfig/cron/v3 v3.0.1
github.com/sagernet/sing v0.7.0-beta.1.0.20250722151551-64142925accb
github.com/sagernet/sing-box v1.12.0-rc.3
github.com/sagernet/sing v0.7.18
github.com/sagernet/sing-box v1.12.23
github.com/sagernet/sing-dns v0.4.6
github.com/shirou/gopsutil/v4 v4.25.6
github.com/shirou/gopsutil/v4 v4.26.1
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/sqlite v1.6.0
gorm.io/gorm v1.30.0
gorm.io/gorm v1.31.1
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/akutz/memconn v0.1.0 // indirect
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/anytls/sing-anytls v0.0.8 // indirect
github.com/anytls/sing-anytls v0.0.11 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/bytedance/sonic v1.13.3 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
github.com/caddyserver/certmagic v0.23.0 // indirect
github.com/caddyserver/zerossl v0.1.3 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/coder/websocket v1.8.13 // indirect
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 // indirect
github.com/cretz/bine v0.2.0 // indirect
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa // indirect
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e // indirect
github.com/ebitengine/purego v0.8.4 // indirect
github.com/ebitengine/purego v0.9.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/gaissmai/bart v0.11.1 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-chi/chi/v5 v5.2.2 // indirect
@@ -49,18 +50,19 @@ require (
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
github.com/go-playground/validator/v10 v10.28.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 // indirect
github.com/gofrs/uuid/v5 v5.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/nftables v0.2.1-0.20240414091927-5e242ec57806 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/csrf v1.7.3-0.20250123201450-9dd6af1f6d30 // indirect
github.com/gorilla/csrf v1.7.3 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/sessions v1.4.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
@@ -72,7 +74,7 @@ require (
github.com/jsimonetti/rtnetlink v1.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/libdns/alidns v1.0.5-libdns.v1.beta1 // indirect
@@ -81,13 +83,13 @@ require (
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.28 // indirect
github.com/mattn/go-sqlite3 v1.14.30 // indirect
github.com/mdlayher/genetlink v1.3.2 // indirect
github.com/mdlayher/netlink v1.7.3-0.20250113171957-fbb4dce95f42 // indirect
github.com/mdlayher/sdnotify v1.0.0 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422 // indirect
github.com/metacubex/utls v1.8.0 // indirect
github.com/metacubex/tfo-go v0.0.0-20250921095601-b102db4216c0 // indirect
github.com/metacubex/utls v1.8.4 // indirect
github.com/mholt/acmez/v3 v3.1.2 // indirect
github.com/miekg/dns v1.1.67 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
@@ -98,6 +100,7 @@ require (
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus-community/pro-bing v0.4.0 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.55.0 // indirect
github.com/safchain/ethtool v0.3.0 // indirect
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
github.com/sagernet/cors v1.2.1 // indirect
@@ -105,16 +108,16 @@ require (
github.com/sagernet/gvisor v0.0.0-20250325023245-7a9c0f5725fb // indirect
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
github.com/sagernet/quic-go v0.52.0-beta.1 // indirect
github.com/sagernet/sing-mux v0.3.2 // indirect
github.com/sagernet/sing-quic v0.5.0-beta.3 // indirect
github.com/sagernet/quic-go v0.52.0-sing-box-mod.3 // indirect
github.com/sagernet/sing-mux v0.3.4 // indirect
github.com/sagernet/sing-quic v0.5.3 // indirect
github.com/sagernet/sing-shadowsocks v0.2.8 // indirect
github.com/sagernet/sing-shadowsocks2 v0.2.1 // indirect
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 // indirect
github.com/sagernet/sing-tun v0.6.10-0.20250721014417-ebbe32588cfb // indirect
github.com/sagernet/sing-vmess v0.2.4 // indirect
github.com/sagernet/smux v1.5.34-mod.2 // indirect
github.com/sagernet/tailscale v1.80.3-mod.5 // indirect
github.com/sagernet/sing-tun v0.7.11 // indirect
github.com/sagernet/sing-vmess v0.2.7 // indirect
github.com/sagernet/smux v1.5.50-sing-box-mod.1 // indirect
github.com/sagernet/tailscale v1.80.3-sing-box-1.12-mod.2 // indirect
github.com/sagernet/wireguard-go v0.0.1-beta.7 // indirect
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e // indirect
@@ -125,8 +128,8 @@ require (
github.com/tailscale/netlink v1.1.1-0.20240822203006-4d49adab4de7 // indirect
github.com/tailscale/peercred v0.0.0-20250107143737-35a0c7bd7edc // indirect
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976 // indirect
github.com/tklauser/go-sysconf v0.3.15 // indirect
github.com/tklauser/numcpus v0.10.0 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
@@ -139,21 +142,21 @@ require (
go.uber.org/zap/exp v0.3.0 // indirect
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/arch v0.18.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/arch v0.22.0 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
golang.org/x/mod v0.26.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/term v0.33.0 // indirect
golang.org/x/text v0.27.0 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/time v0.9.0 // indirect
golang.org/x/tools v0.34.0 // indirect
golang.org/x/tools v0.39.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
google.golang.org/grpc v1.73.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
google.golang.org/protobuf v1.36.10 // indirect
lukechampine.com/blake3 v1.4.1 // indirect
)
+90 -86
View File
@@ -1,5 +1,9 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw=
filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/akutz/memconn v0.1.0 h1:NawI0TORU4hcOMsMr11g7vwlCdkYeLKXBcxWu2W/P8A=
@@ -8,24 +12,24 @@ github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7V
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/anytls/sing-anytls v0.0.8 h1:1u/fnH1HoeeMV5mX7/eUOjLBvPdkd1UJRmXiRi6Vymc=
github.com/anytls/sing-anytls v0.0.8/go.mod h1:7rjN6IukwysmdusYsrV51Fgu1uW6vsrdd6ctjnEAln8=
github.com/anytls/sing-anytls v0.0.11 h1:w8e9Uj1oP3m4zxkyZDewPk0EcQbvVxb7Nn+rapEx4fc=
github.com/anytls/sing-anytls v0.0.11/go.mod h1:7rjN6IukwysmdusYsrV51Fgu1uW6vsrdd6ctjnEAln8=
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0=
github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/caddyserver/certmagic v0.23.0 h1:CfpZ/50jMfG4+1J/u2LV6piJq4HOfO6ppOnOf7DkFEU=
github.com/caddyserver/certmagic v0.23.0/go.mod h1:9mEZIWqqWoI+Gf+4Trh04MOVPD0tGSxtqsxg87hAIH4=
github.com/caddyserver/zerossl v0.1.3 h1:onS+pxp3M8HnHpN5MMbOMyNjmTheJyWRaZYwn+YTAyA=
github.com/caddyserver/zerossl v0.1.3/go.mod h1:CxA0acn7oEGO6//4rtrRjYgEoa4MFw/XofZnrYwGqG4=
github.com/cilium/ebpf v0.15.0 h1:7NxJhNiBT3NG8pZJ3c+yfrVdHY8ScgKD27sScgjLMMk=
github.com/cilium/ebpf v0.15.0/go.mod h1:DHp1WyrLeiBh19Cf/tfiSMhqheEiK8fXFZ4No0P1Hso=
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 h1:8h5+bWd7R6AYUslN6c6iuZWTKsKxUFDlpnmilO6R2n0=
@@ -40,24 +44,24 @@ github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa h1:h8TfIT1xc8FWbww
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa/go.mod h1:Nx87SkVqTKd8UtT+xu7sM/l+LgXs6c0aHrlKusR+2EQ=
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e h1:vUmf0yezR0y7jJ5pceLHthLaYf4bA5T14B6q39S4q2Q=
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e/go.mod h1:YTIHhz/QFSYnu/EhlF2SpU2Uk+32abacUYA5ZPljz1A=
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s0A=
github.com/ebitengine/purego v0.9.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gaissmai/bart v0.11.1 h1:5Uv5XwsaFBRo4E5VBcb9TzY8B7zxFf+U7isDxqOrRfc=
github.com/gaissmai/bart v0.11.1/go.mod h1:KHeYECXQiBjTzQz/om2tqn3sZF1J7hw9m6z41ftj3fg=
github.com/gin-contrib/gzip v1.2.3 h1:dAhT722RuEG330ce2agAs75z7yB+NKvX/ZM1r8w0u2U=
github.com/gin-contrib/gzip v1.2.3/go.mod h1:ad72i4Bzmaypk8M762gNXa2wkxxjbz0icRNnuLJ9a/c=
github.com/gin-contrib/gzip v1.2.5 h1:fIZs0S+l17pIu1P5XRJOo/YNqfIuPCrZZ3TWB7pjckI=
github.com/gin-contrib/gzip v1.2.5/go.mod h1:aomRgR7ftdZV3uWY0gW/m8rChfxau0n8YVvwlOHONzw=
github.com/gin-contrib/sessions v1.0.4 h1:ha6CNdpYiTOK/hTp05miJLbpTSNfOnFg5Jm2kbcqy8U=
github.com/gin-contrib/sessions v1.0.4/go.mod h1:ccmkrb2z6iU2osiAHZG3x3J4suJK+OU27oqzlWOqQgs=
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
github.com/github/fakeca v0.1.0 h1:Km/MVOFvclqxPM9dZBC4+QE564nU4gz4iZ0D9pMw28I=
github.com/github/fakeca v0.1.0/go.mod h1:+bormgoGMMuamOscx7N91aOuUST7wdaJ2rNjeohylyo=
github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618=
@@ -79,18 +83,20 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 h1:sQspH8M4niEijh3PFscJRLDnkL547IeP7kpPe3uUhEg=
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466/go.mod h1:ZiQxhyQ+bbbfxUKVvjfO498oPYvtYhZzycal3G/NHmU=
github.com/gofrs/uuid/v5 v5.3.2 h1:2jfO8j3XgSwlz/wHqemAEugfnTlikAYHhnqQ8Xh4fE0=
github.com/gofrs/uuid/v5 v5.3.2/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0=
github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
@@ -108,8 +114,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
github.com/gorilla/csrf v1.7.3-0.20250123201450-9dd6af1f6d30 h1:fiJdrgVBkjZ5B1HJ2WQwNOaXB+QyYcNXTA3t1XYLz0M=
github.com/gorilla/csrf v1.7.3-0.20250123201450-9dd6af1f6d30/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
github.com/gorilla/csrf v1.7.3 h1:BHWt6FTLZAb2HtWT5KDBf6qgpZzvtbp9QWDRKZMXJC0=
github.com/gorilla/csrf v1.7.3/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
@@ -132,10 +138,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a h1:+RR6SqnTkDLWyICxS1xpjCi/3dhyV+TgZwA6Ww3KncQ=
github.com/kortschak/wol v0.0.0-20200729010619-da482cc4850a/go.mod h1:YTtCCM3ryyfiu4F7t8HQ1mxvp1UBdWM2r6Xa+nGWvDk=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
@@ -153,8 +157,8 @@ github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr32
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A=
github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.30 h1:bVreufq3EAIG1Quvws73du3/QgdeZ3myglJlrzSYYCY=
github.com/mattn/go-sqlite3 v1.14.30/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mdlayher/genetlink v1.3.2 h1:KdrNKe+CTu+IbZnm/GVUMXSqBBLqcGpRDa0xkQy56gw=
github.com/mdlayher/genetlink v1.3.2/go.mod h1:tcC3pkCrPUGIKKsCsp0B3AdaaKuHtaxoJRz3cc+528o=
github.com/mdlayher/netlink v1.7.3-0.20250113171957-fbb4dce95f42 h1:A1Cq6Ysb0GM0tpKMbdCXCIfBclan4oHk1Jb+Hrejirg=
@@ -163,10 +167,10 @@ github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ
github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE=
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422 h1:zGeQt3UyNydIVrMRB97AA5WsYEau/TyCnRtTf1yUmJY=
github.com/metacubex/tfo-go v0.0.0-20241231083714-66613d49c422/go.mod h1:l9oLnLoEXyGZ5RVLsh7QCC5XsouTUyKk4F2nLm2DHLw=
github.com/metacubex/utls v1.8.0 h1:mSYi6FMnmc5riARl5UZDmWVy710z+P5b7xuGW0lV9ac=
github.com/metacubex/utls v1.8.0/go.mod h1:FdjYzVfCtgtna19hX0ER1Xsa5uJInwdQ4IcaaI98lEQ=
github.com/metacubex/tfo-go v0.0.0-20250921095601-b102db4216c0 h1:Ui+/2s5Qz0lSnDUBmEL12M5Oi/PzvFxGTNohm8ZcsmE=
github.com/metacubex/tfo-go v0.0.0-20250921095601-b102db4216c0/go.mod h1:l9oLnLoEXyGZ5RVLsh7QCC5XsouTUyKk4F2nLm2DHLw=
github.com/metacubex/utls v1.8.4 h1:HmL9nUApDdWSkgUyodfwF6hSjtiwCGGdyhaSpEejKpg=
github.com/metacubex/utls v1.8.4/go.mod h1:kncGGVhFaoGn5M3pFe3SXhZCzsbCJayNOH4UEqTKTko=
github.com/mholt/acmez/v3 v3.1.2 h1:auob8J/0FhmdClQicvJvuDavgd5ezwLBfKuYmynhYzc=
github.com/mholt/acmez/v3 v3.1.2/go.mod h1:L1wOU06KKvq7tswuMDwKdcHeKpFFgkppZy/y0DFxagQ=
github.com/miekg/dns v1.1.67 h1:kg0EHj0G4bfT5/oOys6HhZw4vmMlnoZ+gDu8tJ/AlI0=
@@ -195,6 +199,8 @@ github.com/prometheus-community/pro-bing v0.4.0 h1:YMbv+i08gQz97OZZBwLyvmmQEEzyf
github.com/prometheus-community/pro-bing v0.4.0/go.mod h1:b7wRYZtCcPmt4Sz319BykUU241rWLe1VFXyiyWK/dH4=
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9Mk=
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0=
@@ -211,39 +217,38 @@ github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZN
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
github.com/sagernet/quic-go v0.52.0-beta.1 h1:hWkojLg64zjV+MJOvJU/kOeWndm3tiEfBLx5foisszs=
github.com/sagernet/quic-go v0.52.0-beta.1/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
github.com/sagernet/sing v0.6.9/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing v0.7.0-beta.1.0.20250722151551-64142925accb h1:9DU5JA9Cow/bUfdP1v1pYMbAkFiW17UbI4b/iEPjVnc=
github.com/sagernet/sing v0.7.0-beta.1.0.20250722151551-64142925accb/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing-box v1.12.0-rc.3 h1:2II6wtPSAZZtE7+1EvdoEo1M0+De8483sqwMd8evaos=
github.com/sagernet/sing-box v1.12.0-rc.3/go.mod h1:9HHuLZi2GS3xaDT9oh9hpXsaoEB71HN8YM03lctYB10=
github.com/sagernet/quic-go v0.52.0-sing-box-mod.3 h1:ySqffGm82rPqI1TUPqmtHIYd12pfEGScygnOxjTL56w=
github.com/sagernet/quic-go v0.52.0-sing-box-mod.3/go.mod h1:OV+V5kEBb8kJS7k29MzDu6oj9GyMc7HA07sE1tedxz4=
github.com/sagernet/sing v0.7.18 h1:iZHkaru1/MoHugx3G+9S3WG4owMewKO/KvieE2Pzk4E=
github.com/sagernet/sing v0.7.18/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing-box v1.12.23 h1:egmRGPpzMZVmc4iCl0T1wBBAZea3NTxDmi//b3sXSsQ=
github.com/sagernet/sing-box v1.12.23/go.mod h1:jjM3DQWWJSMW3U0uv3AxYRjyLnHu/SXN3A6Svex83/w=
github.com/sagernet/sing-dns v0.4.6 h1:mjZC0o6d5sQ1sraoOBbK3G3apCbuL8wWYwu2RNu5rbM=
github.com/sagernet/sing-dns v0.4.6/go.mod h1:dweQs54ng2YGzoJfz+F9dGuDNdP5pJ3PLeggnK5VWc8=
github.com/sagernet/sing-mux v0.3.2 h1:meZVFiiStvHThb/trcpAkCrmtJOuItG5Dzl1RRP5/NE=
github.com/sagernet/sing-mux v0.3.2/go.mod h1:pht8iFY4c9Xltj7rhVd208npkNaeCxzyXCgulDPLUDA=
github.com/sagernet/sing-quic v0.5.0-beta.3 h1:X/acRNsqQNfDlmwE7SorHfaZiny5e67hqIzM/592ric=
github.com/sagernet/sing-quic v0.5.0-beta.3/go.mod h1:SAv/qdeDN+75msGG5U5ZIwG+3Ua50jVIKNrRSY8pkx0=
github.com/sagernet/sing-mux v0.3.4 h1:ZQplKl8MNXutjzbMVtWvWG31fohhgOfCuUZR4dVQ8+s=
github.com/sagernet/sing-mux v0.3.4/go.mod h1:QvlKMyNBNrQoyX4x+gq028uPbLM2XeRpWtDsWBJbFSk=
github.com/sagernet/sing-quic v0.5.3 h1:K937DKJN98xqyztijRkLJqbBfyV4rEZcYxFyP3EBikU=
github.com/sagernet/sing-quic v0.5.3/go.mod h1:evP1e++ZG8TJHVV5HudXV4vWeYzGfCdF4HwSJZcdqkI=
github.com/sagernet/sing-shadowsocks v0.2.8 h1:PURj5PRoAkqeHh2ZW205RWzN9E9RtKCVCzByXruQWfE=
github.com/sagernet/sing-shadowsocks v0.2.8/go.mod h1:lo7TWEMDcN5/h5B8S0ew+r78ZODn6SwVaFhvB6H+PTI=
github.com/sagernet/sing-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnqqs2gQ2/Qioo=
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 h1:tK+75l64tm9WvEFrYRE1t0YxoFdWQqw/h7Uhzj0vJ+w=
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
github.com/sagernet/sing-tun v0.6.10-0.20250721014417-ebbe32588cfb h1:cvHEzjk3sVy80UA9PFKX15MzSP0g1uKwUspOm2ds3no=
github.com/sagernet/sing-tun v0.6.10-0.20250721014417-ebbe32588cfb/go.mod h1:AHJuRrLbNRJuivuFZ2VhXwDj4ViYp14szG5EkkKAqRQ=
github.com/sagernet/sing-vmess v0.2.4 h1:wSg/SdxThELAvoRIN2yCZgu5xsmP1FWPBrP2ab2wq3A=
github.com/sagernet/sing-vmess v0.2.4/go.mod h1:5aYoOtYksAyS0NXDm0qKeTYW1yoE1bJVcv+XLcVoyJs=
github.com/sagernet/smux v1.5.34-mod.2 h1:gkmBjIjlJ2zQKpLigOkFur5kBKdV6bNRoFu2WkltRQ4=
github.com/sagernet/smux v1.5.34-mod.2/go.mod h1:0KW0+R+ycvA2INW4gbsd7BNyg+HEfLIAxa5N02/28Zc=
github.com/sagernet/tailscale v1.80.3-mod.5 h1:7V7z+p2C//TGtff20pPnDCt3qP6uFyY62peJoKF9z/A=
github.com/sagernet/tailscale v1.80.3-mod.5/go.mod h1:EBxXsWu4OH2ELbQLq32WoBeIubG8KgDrg4/Oaxjs6lI=
github.com/sagernet/sing-tun v0.7.11 h1:qB7jy8JKqXg73fYBsDkBSy4ulRSbLrFut0e+y+QPhqU=
github.com/sagernet/sing-tun v0.7.11/go.mod h1:pUEjh9YHQ2gJT6Lk0TYDklh3WJy7lz+848vleGM3JPM=
github.com/sagernet/sing-vmess v0.2.7 h1:2ee+9kO0xW5P4mfe6TYVWf9VtY8k1JhNysBqsiYj0sk=
github.com/sagernet/sing-vmess v0.2.7/go.mod h1:5aYoOtYksAyS0NXDm0qKeTYW1yoE1bJVcv+XLcVoyJs=
github.com/sagernet/smux v1.5.50-sing-box-mod.1 h1:XkJcivBC9V4wBjiGXIXZ229aZCU1hzcbp6kSkkyQ478=
github.com/sagernet/smux v1.5.50-sing-box-mod.1/go.mod h1:NjhsCEWedJm7eFLyhuBgIEzwfhRmytrUoiLluxs5Sk8=
github.com/sagernet/tailscale v1.80.3-sing-box-1.12-mod.2 h1:MO7s4ni2bSfAOhcan2rdQSWCztkMXmqyg6jYPZp8bEE=
github.com/sagernet/tailscale v1.80.3-sing-box-1.12-mod.2/go.mod h1:EBxXsWu4OH2ELbQLq32WoBeIubG8KgDrg4/Oaxjs6lI=
github.com/sagernet/wireguard-go v0.0.1-beta.7 h1:ltgBwYHfr+9Wz1eG59NiWnHrYEkDKHG7otNZvu85DXI=
github.com/sagernet/wireguard-go v0.0.1-beta.7/go.mod h1:jGXij2Gn2wbrWuYNUmmNhf1dwcZtvyAvQoe8Xd8MbUo=
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 h1:6uUiZcDRnZSAegryaUGwPC/Fj13JSHwiTftrXhMmYOc=
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854/go.mod h1:LtfoSK3+NG57tvnVEHgcuBW9ujgE8enPSgzgwStwCAA=
github.com/shirou/gopsutil/v4 v4.25.6 h1:kLysI2JsKorfaFPcYmcJqbzROzsBWEOAtw6A7dIfqXs=
github.com/shirou/gopsutil/v4 v4.25.6/go.mod h1:PfybzyydfZcN+JMMjkF6Zb8Mq1A/VcogFFg7hj50W9c=
github.com/shirou/gopsutil/v4 v4.26.1 h1:TOkEyriIXk2HX9d4isZJtbjXbEjf5qyKPAzbzY0JWSo=
github.com/shirou/gopsutil/v4 v4.26.1/go.mod h1:medLI9/UNAb0dOI9Q3/7yWSqKkj00u+1tgY8nvv41pc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -252,11 +257,10 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e h1:PtWT87weP5LWHEY//SWsYkSO3RWRZo4OSWagh3YD2vQ=
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e/go.mod h1:XrBNfAFN+pwoWuksbFS9Ccxnopa15zJGgXRFN90l3K4=
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55 h1:Gzfnfk2TWrk8Jj4P4c1a3CtQyMaTVCznlkLZI++hok4=
@@ -275,10 +279,10 @@ github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976 h1:U
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976/go.mod h1:agQPE6y6ldqCOui2gkIh7ZMztTkIQKH049tv8siLuNQ=
github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA=
github.com/tc-hib/winres v0.2.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4=
github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4=
github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 h1:pyC9PaHYZFgEKFdlp3G8RaCKgVpHZnecvArXvPXcFkM=
@@ -312,6 +316,8 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
@@ -322,24 +328,24 @@ go4.org/mem v0.0.0-20240501181205-ae6ca9944745 h1:Tl++JLUCe4sxGu8cTpDzRLd3tN7US4
go4.org/mem v0.0.0-20240501181205-ae6ca9944745/go.mod h1:reUoABIJ9ikfM5sgtSF3Wushcza7+WeD01VB9Lirh3g=
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc=
golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68=
golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY=
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -349,21 +355,20 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg=
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10 h1:3GDAcqdIg1ozBNLgPy4SLT84nfcBjr6rhGtXYtrkWLU=
@@ -374,8 +379,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
@@ -383,10 +388,9 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
gorm.io/gorm v1.30.0 h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs=
gorm.io/gorm v1.30.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
lukechampine.com/blake3 v1.4.1 h1:I3Smz7gso8w4/TunLKec6K2fn+kyKtDxr/xcQEN84Wg=
lukechampine.com/blake3 v1.4.1/go.mod h1:QFosUxmjB8mnrWFSNwKmvxHpfY72bmD2tQ0kBMM3kwo=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
software.sslmate.com/src/go-pkcs12 v0.4.0 h1:H2g08FrTvSFKUj+D309j1DPfk5APnIdAQAB8aEykJ5k=
software.sslmate.com/src/go-pkcs12 v0.4.0/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI=
-60
View File
@@ -38,66 +38,6 @@ arch() {
echo "arch: $(arch)"
os_version=""
os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
if [[ "${release}" == "arch" ]]; then
echo "Your OS is Arch Linux"
elif [[ "${release}" == "parch" ]]; then
echo "Your OS is Parch linux"
elif [[ "${release}" == "manjaro" ]]; then
echo "Your OS is Manjaro"
elif [[ "${release}" == "armbian" ]]; then
echo "Your OS is Armbian"
elif [[ "${release}" == "opensuse-tumbleweed" ]]; then
echo "Your OS is OpenSUSE Tumbleweed"
elif [[ "${release}" == "centos" ]]; then
if [[ ${os_version} -lt 8 ]]; then
echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "ubuntu" ]]; then
if [[ ${os_version} -lt 20 ]]; then
echo -e "${red} Please use Ubuntu 20 or higher version!${plain}\n" && exit 1
fi
elif [[ "${release}" == "fedora" ]]; then
if [[ ${os_version} -lt 36 ]]; then
echo -e "${red} Please use Fedora 36 or higher version!${plain}\n" && exit 1
fi
elif [[ "${release}" == "debian" ]]; then
if [[ ${os_version} -lt 11 ]]; then
echo -e "${red} Please use Debian 11 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "almalinux" ]]; then
if [[ ${os_version} -lt 9 ]]; then
echo -e "${red} Please use AlmaLinux 9 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "rocky" ]]; then
if [[ ${os_version} -lt 9 ]]; then
echo -e "${red} Please use Rocky Linux 9 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "ol" ]]; then
if [[ ${os_version} -lt 8 ]]; then
echo -e "${red} Please use Oracle Linux 8 or higher ${plain}\n" && exit 1
fi
else
echo -e "${red}Your operating system is not supported by this script.${plain}\n"
echo "Please ensure you are using one of the following supported operating systems:"
echo "- Ubuntu 20.04+"
echo "- Debian 11+"
echo "- CentOS 8+"
echo "- Fedora 36+"
echo "- Arch Linux"
echo "- Parch Linux"
echo "- Manjaro"
echo "- Armbian"
echo "- AlmaLinux 9+"
echo "- Rocky Linux 9+"
echo "- Oracle Linux 8+"
echo "- OpenSUSE Tumbleweed"
exit 1
fi
install_base() {
case "${release}" in
centos | almalinux | rocky | oracle)
+17 -6
View File
@@ -23,15 +23,26 @@ func InitLogger(level logging.Level) {
var backend logging.Backend
var format logging.Formatter
backend, err = logging.NewSyslogBackend("")
if err != nil {
fmt.Println("Unable to use syslog: " + err.Error())
backend = logging.NewLogBackend(os.Stderr, "", 0)
_, inContainer := os.LookupEnv("container")
if !inContainer {
if _, statErr := os.Stat("/.dockerenv"); statErr == nil {
inContainer = true
}
}
if err != nil {
if inContainer {
backend = logging.NewLogBackend(os.Stderr, "", 0)
format = logging.MustStringFormatter(`%{time:2006/01/02 15:04:05} %{level} - %{message}`)
} else {
format = logging.MustStringFormatter(`%{level} - %{message}`)
backend, err = logging.NewSyslogBackend("")
if err != nil {
fmt.Println("Unable to use syslog: " + err.Error())
backend = logging.NewLogBackend(os.Stderr, "", 0)
}
if err != nil {
format = logging.MustStringFormatter(`%{time:2006/01/02 15:04:05} %{level} - %{message}`)
} else {
format = logging.MustStringFormatter(`%{level} - %{message}`)
}
}
backendFormatter := logging.NewBackendFormatter(backend, format)
+3 -2
View File
@@ -4,9 +4,10 @@ import (
"log"
"os"
"os/signal"
"s-ui/app"
"s-ui/cmd"
"syscall"
"github.com/alireza0/s-ui/app"
"github.com/alireza0/s-ui/cmd"
)
func runApp() {
-6
View File
@@ -1,6 +0,0 @@
{
"name": "s-ui",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
-59
View File
@@ -32,65 +32,6 @@ fi
echo "The OS release is: $release"
os_version=""
os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
if [[ "${release}" == "arch" ]]; then
echo "Your OS is Arch Linux"
elif [[ "${release}" == "parch" ]]; then
echo "Your OS is Parch linux"
elif [[ "${release}" == "manjaro" ]]; then
echo "Your OS is Manjaro"
elif [[ "${release}" == "armbian" ]]; then
echo "Your OS is Armbian"
elif [[ "${release}" == "opensuse-tumbleweed" ]]; then
echo "Your OS is OpenSUSE Tumbleweed"
elif [[ "${release}" == "centos" ]]; then
if [[ ${os_version} -lt 8 ]]; then
echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "ubuntu" ]]; then
if [[ ${os_version} -lt 22 ]]; then
echo -e "${red} Please use Ubuntu 22 or higher version!${plain}\n" && exit 1
fi
elif [[ "${release}" == "fedora" ]]; then
if [[ ${os_version} -lt 36 ]]; then
echo -e "${red} Please use Fedora 36 or higher version!${plain}\n" && exit 1
fi
elif [[ "${release}" == "debian" ]]; then
if [[ ${os_version} -lt 11 ]]; then
echo -e "${red} Please use Debian 11 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "almalinux" ]]; then
if [[ ${os_version} -lt 9 ]]; then
echo -e "${red} Please use AlmaLinux 9 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "rocky" ]]; then
if [[ ${os_version} -lt 9 ]]; then
echo -e "${red} Please use Rocky Linux 9 or higher ${plain}\n" && exit 1
fi
elif [[ "${release}" == "oracle" ]]; then
if [[ ${os_version} -lt 8 ]]; then
echo -e "${red} Please use Oracle Linux 8 or higher ${plain}\n" && exit 1
fi
else
echo -e "${red}Your operating system is not supported by this script.${plain}\n"
echo "Please ensure you are using one of the following supported operating systems:"
echo "- Ubuntu 22.04+"
echo "- Debian 11+"
echo "- CentOS 8+"
echo "- Fedora 36+"
echo "- Arch Linux"
echo "- Parch Linux"
echo "- Manjaro"
echo "- Armbian"
echo "- AlmaLinux 9+"
echo "- Rocky Linux 9+"
echo "- Oracle Linux 8+"
echo "- OpenSUSE Tumbleweed"
exit 1
fi
confirm() {
if [[ $# > 1 ]]; then
echo && read -p "$1 [Default$2]: " temp
+25 -12
View File
@@ -3,14 +3,15 @@ package service
import (
"bytes"
"encoding/json"
"s-ui/database"
"s-ui/database/model"
"s-ui/logger"
"s-ui/util"
"s-ui/util/common"
"strings"
"time"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
@@ -221,10 +222,16 @@ func (s *ClientService) UpdateClientsOnInboundAdd(tx *gorm.DB, initIds string, i
}
func (s *ClientService) UpdateClientsOnInboundDelete(tx *gorm.DB, id uint, tag string) error {
var clientIds []uint
err := tx.Raw("SELECT clients.id FROM clients, json_each(clients.inbounds) AS je WHERE je.value = ?", id).Scan(&clientIds).Error
if err != nil {
return err
}
if len(clientIds) == 0 {
return nil
}
var clients []model.Client
err := tx.Table("clients").
Where("EXISTS (SELECT 1 FROM json_each(clients.inbounds) WHERE json_each.value = ?)", id).
Find(&clients).Error
err = tx.Model(model.Client{}).Where("id IN ?", clientIds).Find(&clients).Error
if err != nil {
return err
}
@@ -264,10 +271,16 @@ func (s *ClientService) UpdateClientsOnInboundDelete(tx *gorm.DB, id uint, tag s
func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounds *[]model.Inbound, hostname string, oldTag string) error {
var err error
for _, inbound := range *inbounds {
var clientIds []uint
err = tx.Raw("SELECT clients.id FROM clients, json_each(clients.inbounds) AS je WHERE je.value = ?", inbound.Id).Scan(&clientIds).Error
if err != nil {
return err
}
if len(clientIds) == 0 {
continue
}
var clients []model.Client
err = tx.Table("clients").
Where("EXISTS (SELECT 1 FROM json_each(clients.inbounds) WHERE json_each.value = ?)", inbound.Id).
Find(&clients).Error
err = tx.Model(model.Client{}).Where("id IN ?", clientIds).Find(&clients).Error
if err != nil {
return err
}
@@ -283,7 +296,7 @@ func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounds *[]mode
})
}
for _, clientLink := range clientLinks {
if clientLink["remark"] != inbound.Tag && clientLink["remark"] != oldTag {
if clientLink["type"] != "local" || (clientLink["remark"] != inbound.Tag && clientLink["remark"] != oldTag) {
newClientLinks = append(newClientLinks, clientLink)
}
}
+53 -20
View File
@@ -2,13 +2,14 @@ package service
import (
"encoding/json"
"s-ui/core"
"s-ui/database"
"s-ui/database/model"
"s-ui/logger"
"s-ui/util/common"
"strconv"
"time"
"github.com/alireza0/s-ui/core"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
)
var (
@@ -43,7 +44,7 @@ func NewConfigService(core *core.Core) *ConfigService {
return &ConfigService{}
}
func (s *ConfigService) GetConfig(data string) (*SingBoxConfig, error) {
func (s *ConfigService) GetConfig(data string) (*[]byte, error) {
var err error
if len(data) == 0 {
data, err = s.SettingService.GetConfig()
@@ -73,22 +74,22 @@ func (s *ConfigService) GetConfig(data string) (*SingBoxConfig, error) {
if err != nil {
return nil, err
}
return &singboxConfig, nil
rawConfig, err := json.MarshalIndent(singboxConfig, "", " ")
if err != nil {
return nil, err
}
return &rawConfig, nil
}
func (s *ConfigService) StartCore(defaultConfig string) error {
func (s *ConfigService) StartCore() error {
if corePtr.IsRunning() {
return nil
}
singboxConfig, err := s.GetConfig(defaultConfig)
rawConfig, err := s.GetConfig("")
if err != nil {
return err
}
rawConfig, err := json.MarshalIndent(singboxConfig, "", " ")
if err != nil {
return err
}
err = corePtr.Start(rawConfig)
err = corePtr.Start(*rawConfig)
if err != nil {
logger.Error("start sing-box err:", err.Error())
return err
@@ -102,15 +103,34 @@ func (s *ConfigService) RestartCore() error {
if err != nil {
return err
}
return s.StartCore("")
return s.StartCore()
}
func (s *ConfigService) restartCoreWithConfig(config json.RawMessage) error {
err := s.StopCore()
var err error
defer func() {
if err != nil {
corePtr.Stop()
logger.Error("restart sing-box err:", err.Error())
} else {
logger.Info("sing-box restarted with new config")
}
}()
if corePtr.IsRunning() {
err = corePtr.GetInstance().Close()
if err != nil {
return err
}
}
rawConfig, err := s.GetConfig(string(config))
if err != nil {
return err
}
return s.StartCore(string(config))
err = corePtr.Start(*rawConfig)
if err != nil {
return err
}
return nil
}
func (s *ConfigService) StopCore() error {
@@ -122,6 +142,16 @@ func (s *ConfigService) StopCore() error {
return nil
}
func (s *ConfigService) CheckOutbound(tag string, link string) core.CheckOutboundResult {
if tag == "" {
return core.CheckOutboundResult{Error: "missing query parameter: tag"}
}
if corePtr == nil || !corePtr.IsRunning() {
return core.CheckOutboundResult{Error: "core not running"}
}
return core.CheckOutbound(corePtr.GetCtx(), tag, link)
}
func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initUsers string, loginUser string, hostname string) ([]string, error) {
var err error
var objs []string = []string{obj}
@@ -133,7 +163,7 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
tx.Commit()
// Try to start core if it is not running
if !corePtr.IsRunning() {
s.StartCore("")
s.StartCore()
}
} else {
tx.Rollback()
@@ -142,7 +172,8 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
switch obj {
case "clients":
inboundIds, err := s.ClientService.Save(tx, act, data, hostname)
var inboundIds []uint
inboundIds, err = s.ClientService.Save(tx, act, data, hostname)
if err == nil && len(inboundIds) > 0 {
objs = append(objs, "inbounds")
err = s.InboundService.RestartInbounds(tx, inboundIds)
@@ -167,7 +198,9 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
if err != nil {
return nil, err
}
err = s.restartCoreWithConfig(data)
configData := make(json.RawMessage, len(data))
copy(configData, data)
go func() { _ = s.restartCoreWithConfig(configData) }()
case "settings":
err = s.SettingService.Save(tx, data)
default:
+4 -3
View File
@@ -3,9 +3,10 @@ package service
import (
"encoding/json"
"os"
"s-ui/database"
"s-ui/database/model"
"s-ui/util/common"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
+5 -4
View File
@@ -4,12 +4,13 @@ import (
"encoding/json"
"fmt"
"os"
"s-ui/database"
"s-ui/database/model"
"s-ui/util"
"s-ui/util/common"
"strings"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/util"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
+4 -3
View File
@@ -3,9 +3,10 @@ package service
import (
"encoding/json"
"os"
"s-ui/database"
"s-ui/database/model"
"s-ui/util/common"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
+8 -2
View File
@@ -2,9 +2,11 @@ package service
import (
"os"
"s-ui/logger"
"runtime"
"syscall"
"time"
"github.com/alireza0/s-ui/logger"
)
type PanelService struct {
@@ -17,7 +19,11 @@ func (s *PanelService) RestartPanel(delay time.Duration) error {
}
go func() {
time.Sleep(delay)
err := p.Signal(syscall.SIGHUP)
if runtime.GOOS == "windows" {
err = p.Kill()
} else {
err = p.Signal(syscall.SIGHUP)
}
if err != nil {
logger.Error("send signal SIGHUP failed:", err)
}
+36 -13
View File
@@ -4,12 +4,15 @@ import (
"encoding/base64"
"os"
"runtime"
"s-ui/config"
"s-ui/logger"
"strconv"
"strings"
"time"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/sagernet/sing-box/common/tls"
"github.com/shirou/gopsutil/v4/cpu"
"github.com/shirou/gopsutil/v4/disk"
@@ -39,10 +42,11 @@ func (s *ServerService) GetStatus(request string) *map[string]interface{} {
case "net":
status["net"] = s.GetNetInfo()
case "sys":
status["uptime"] = s.GetUptime()
status["sys"] = s.GetSystemInfo()
case "sbd":
status["sbd"] = s.GetSingboxInfo()
case "db":
status["db"] = s.GetDatabaseInfo()
}
}
return &status
@@ -58,16 +62,6 @@ func (s *ServerService) GetCpuPercent() float64 {
}
}
func (s *ServerService) GetUptime() uint64 {
upTime, err := host.Uptime()
if err != nil {
logger.Warning("get uptime failed:", err)
return 0
} else {
return upTime
}
}
func (s *ServerService) GetMemInfo() map[string]interface{} {
info := make(map[string]interface{}, 0)
memInfo, err := mem.VirtualMemory()
@@ -191,6 +185,7 @@ func (s *ServerService) GetSystemInfo() map[string]interface{} {
}
info["ipv4"] = ipv4
info["ipv6"] = ipv6
info["bootTime"], _ = host.BootTime()
return info
}
@@ -258,3 +253,31 @@ func (s *ServerService) generateWireGuardKey(pk string) []string {
}
return []string{"PrivateKey: " + wgKeys.String(), "PublicKey: " + wgKeys.PublicKey().String()}
}
func (s *ServerService) GetDatabaseInfo() map[string]int64 {
info := make(map[string]int64, 0)
db := database.GetDB()
if db == nil {
return nil
}
var clientsCount, inboundsCount, outboundsCount, servicesCount, endpointsCount, clientUp, clientDown int64
db.Model(&model.Client{}).Count(&clientsCount)
db.Model(&model.Inbound{}).Count(&inboundsCount)
db.Model(&model.Outbound{}).Count(&outboundsCount)
db.Model(&model.Service{}).Count(&servicesCount)
db.Model(&model.Endpoint{}).Count(&endpointsCount)
db.Model(&model.Client{}).Select("COALESCE(SUM(up),0)").Scan(&clientUp)
db.Model(&model.Client{}).Select("COALESCE(SUM(down),0)").Scan(&clientDown)
info["clients"] = clientsCount
info["inbounds"] = inboundsCount
info["outbounds"] = outboundsCount
info["services"] = servicesCount
info["endpoints"] = endpointsCount
info["clientUp"] = clientUp
info["clientDown"] = clientDown
return info
}
+4 -3
View File
@@ -3,9 +3,10 @@ package service
import (
"encoding/json"
"os"
"s-ui/database"
"s-ui/database/model"
"s-ui/util/common"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
+20 -5
View File
@@ -3,15 +3,17 @@ package service
import (
"encoding/json"
"os"
"s-ui/config"
"s-ui/database"
"s-ui/database/model"
"s-ui/logger"
"s-ui/util/common"
"runtime"
"strconv"
"strings"
"time"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
@@ -25,6 +27,9 @@ var defaultConfig = `{
},
"route": {
"rules": [
{
"action": "sniff"
},
{
"protocol": [
"dns"
@@ -242,6 +247,9 @@ func (s *SettingService) GetTimeLocation() (*time.Location, error) {
if err != nil {
return nil, err
}
if runtime.GOOS == "windows" {
l = "Local"
}
location, err := time.LoadLocation(l)
if err != nil {
defaultLocation := defaultValueMap["timeLocation"]
@@ -384,6 +392,13 @@ func (s *SettingService) Save(tx *gorm.DB, data json.RawMessage) error {
}
}
// Delete all stats if it is set to 0
if key == "trafficAge" && obj == "0" {
err = tx.Where("id > 0").Delete(model.Stats{}).Error
if err != nil {
return err
}
}
err = tx.Model(model.Setting{}).Where("key = ?", key).Update("value", obj).Error
if err != nil {
return err
+9 -6
View File
@@ -1,10 +1,11 @@
package service
import (
"s-ui/database"
"s-ui/database/model"
"time"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"gorm.io/gorm"
)
@@ -19,11 +20,11 @@ var onlineResources = &onlines{}
type StatsService struct {
}
func (s *StatsService) SaveStats() error {
func (s *StatsService) SaveStats(enableTraffic bool) error {
if !corePtr.IsRunning() {
return nil
}
stats := corePtr.GetInstance().ConnTracker().GetStats()
stats := corePtr.GetInstance().StatsTracker().GetStats()
// Reset onlines
onlineResources.Inbound = nil
@@ -70,8 +71,10 @@ func (s *StatsService) SaveStats() error {
}
}
err = tx.Create(&stats).Error
return err
if !enableTraffic {
return nil
}
return tx.Create(&stats).Error
}
func (s *StatsService) GetStats(resource string, tag string, limit int) ([]model.Stats, error) {
+4 -3
View File
@@ -2,9 +2,10 @@ package service
import (
"encoding/json"
"s-ui/database"
"s-ui/database/model"
"s-ui/util/common"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/util/common"
"gorm.io/gorm"
)
+5 -4
View File
@@ -2,11 +2,12 @@ package service
import (
"encoding/json"
"s-ui/database"
"s-ui/database/model"
"s-ui/logger"
"s-ui/util/common"
"time"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
)
type UserService struct {
+4 -3
View File
@@ -8,12 +8,13 @@ import (
"net"
"net/http"
"os"
"s-ui/database/model"
"s-ui/logger"
"s-ui/util/common"
"strconv"
"time"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
+61 -12
View File
@@ -1,11 +1,12 @@
package sub
import (
"s-ui/logger"
"s-ui/service"
"s-ui/util"
"strings"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
"github.com/alireza0/s-ui/util"
"gopkg.in/yaml.v3"
)
@@ -73,8 +74,12 @@ func (s *ClashService) GetClash(subId string) (*string, []string, error) {
}
links := s.LinkService.GetLinks(&client.Links, "external", "")
tagNumEnable := 0
if len(links) > 1 {
tagNumEnable = 1
}
for index, link := range links {
json, tag, err := util.GetOutbound(link, index)
json, tag, err := util.GetOutbound(link, (index+1)*tagNumEnable)
if err == nil && len(tag) > 0 {
*outbounds = append(*outbounds, *json)
*outTags = append(*outTags, tag)
@@ -87,6 +92,9 @@ func (s *ClashService) GetClash(subId string) (*string, []string, error) {
}
result, err := s.ConvertToClashMeta(outbounds)
if err != nil {
return nil, nil, err
}
resultStr := othersStr + "\n" + string(result)
updateInterval, _ := s.SettingService.GetSubUpdates()
@@ -117,14 +125,24 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
proxy := make(map[string]interface{})
proxy["name"] = obMap["tag"]
proxy["type"] = t
proxy["server"] = obMap["server"]
server, _ := obMap["server"].(string)
if len(server) > 0 && strings.Contains(server, ":") && !strings.Contains(server, ".") && !(strings.HasPrefix(server, "[") && strings.HasSuffix(server, "]")) {
server = "'[" + server + "]'"
}
proxy["server"] = server
proxy["port"] = obMap["server_port"]
switch t {
case "vmess", "vless", "tuic":
proxy["uuid"] = obMap["uuid"]
if t == "vmess" {
proxy["alterId"] = obMap["alter_id"]
if alterId, ok := obMap["alter_id"].(float64); ok {
proxy["alterId"] = int(alterId)
} else {
proxy["alterId"] = 0
}
proxy["cipher"] = "auto"
}
if t == "vless" {
@@ -132,6 +150,12 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
proxy["flow"] = flow
}
}
if t == "tuic" {
proxy["password"] = obMap["password"]
if congestion_control, ok := obMap["congestion_control"].(string); ok {
proxy["congestion-controller"] = congestion_control
}
}
case "trojan":
proxy["password"] = obMap["password"]
case "socks", "http":
@@ -162,9 +186,15 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
proxy["obfs"] = obfs["type"]
proxy["obfs-password"] = obfs["password"]
}
if ports, ok := obMap["server_ports"].([]string); ok {
proxy["ports"] = strings.ReplaceAll(strings.Join(ports, ","), ":", "-")
}
if portLists, ok := obMap["server_ports"].([]interface{}); ok {
var ports []string
for _, portList := range portLists {
portRange, _ := portList.(string)
ports = append(ports, strings.ReplaceAll(portRange, ":", "-"))
}
proxy["ports"] = strings.Join(ports, ",")
}
case "anytls":
proxy["password"] = obMap["password"]
@@ -172,6 +202,16 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
proxy["sni"] = tls["server_name"]
proxy["skip-cert-verify"] = tls["insecure"]
}
case "shadowsocks":
proxy["type"] = "ss"
proxy["cipher"] = obMap["method"]
proxy["password"] = obMap["password"]
if network, ok := obMap["network"].(string); ok && network != "tcp" {
proxy["udp"] = true
}
if uot, ok := obMap["udp_over_tcp"].(bool); ok && uot {
proxy["udp-over-tcp"] = true
}
default:
continue
}
@@ -185,10 +225,6 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
}
}
if isTls {
// ignore ech outbounds
if _, ok := tls["ech"].(interface{}); ok {
continue
}
proxy["tls"] = tls["enabled"]
// ALPN if exists
@@ -224,6 +260,19 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
if insecure, ok := tls["insecure"].(bool); ok && insecure {
proxy["skip-cert-verify"] = insecure
}
// ech outbounds
if ech, ok := tls["ech"].(interface{}); ok {
ech_data, _ := ech.(map[string]interface{})
ech_config, _ := ech_data["config"].([]interface{})
ech_string := ""
for i := 1; i < len(ech_config)-1; i++ {
ech_string += ech_config[i].(string)
}
proxy["ech-opts"] = map[string]interface{}{
"enable": true,
"config": ech_string,
}
}
}
// Transport if exist
+40 -10
View File
@@ -3,10 +3,12 @@ package sub
import (
"encoding/json"
"fmt"
"s-ui/database"
"s-ui/database/model"
"s-ui/service"
"s-ui/util"
"strings"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/service"
"github.com/alireza0/s-ui/util"
)
const defaultJson = `
@@ -60,8 +62,12 @@ func (j *JsonService) GetJson(subId string, format string) (*string, []string, e
}
links := j.LinkService.GetLinks(&client.Links, "external", "")
tagNumEnable := 0
if len(links) > 1 {
tagNumEnable = 1
}
for index, link := range links {
json, tag, err := util.GetOutbound(link, index)
json, tag, err := util.GetOutbound(link, (index+1)*tagNumEnable)
if err == nil && len(tag) > 0 {
*outbounds = append(*outbounds, *json)
*outTags = append(*outTags, tag)
@@ -128,12 +134,36 @@ func (j *JsonService) getOutbounds(clientConfig json.RawMessage, inbounds []*mod
return nil, nil, err
}
protocol, _ := outbound["type"].(string)
config, _ := configs[protocol].(map[string]interface{})
for key, value := range config {
if key == "name" || key == "alterId" || (key == "flow" && inData.TlsId == 0) {
continue
// Shadowsocks
if protocol == "shadowsocks" {
var userPass []string
var inbOptions map[string]interface{}
err = json.Unmarshal(inData.Options, &inbOptions)
if err != nil {
return nil, nil, err
}
method, _ := inbOptions["method"].(string)
if strings.HasPrefix(method, "2022") {
inbPass, _ := inbOptions["password"].(string)
userPass = append(userPass, inbPass)
}
var pass string
if method == "2022-blake3-aes-128-gcm" {
pass, _ = configs["shadowsocks16"].(map[string]interface{})["password"].(string)
} else {
pass, _ = configs["shadowsocks"].(map[string]interface{})["password"].(string)
}
userPass = append(userPass, pass)
outbound["password"] = strings.Join(userPass, ":")
} else { // Other protocols
config, _ := configs[protocol].(map[string]interface{})
for key, value := range config {
if key == "name" || key == "alterId" || (key == "flow" && inData.TlsId == 0) {
continue
}
outbound[key] = value
}
outbound[key] = value
}
var addrs []map[string]interface{}
+5 -34
View File
@@ -1,13 +1,11 @@
package sub
import (
"crypto/tls"
"encoding/json"
"io"
"net/http"
"s-ui/logger"
"s-ui/util"
"strings"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util"
)
type Link struct {
@@ -31,7 +29,8 @@ func (s *LinkService) GetLinks(linkJson *json.RawMessage, types string, clientIn
case "external":
result = append(result, link.Uri)
case "sub":
result = append(result, s.getExternalSub(link.Uri)...)
subLinks := util.GetExternalLink(link.Uri)
result = append(result, strings.Split(subLinks, "\n")...)
case "local":
if types == "all" {
result = append(result, s.addClientInfo(link.Uri, clientInfo))
@@ -73,31 +72,3 @@ func (s *LinkService) addClientInfo(uri string, clientInfo string) string {
return uri + clientInfo
}
}
func (s *LinkService) getExternalSub(url string) []string {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
// Make the HTTP request
response, err := client.Get(url)
if err != nil {
logger.Warning("sub: Error making HTTP request:", err)
return nil
}
defer response.Body.Close()
// Read the response body
body, err := io.ReadAll(response.Body)
if err != nil {
logger.Warning("sub: Error reading response body:", err)
return nil
}
// Convert if the content is Base64 encoded
links := util.StrOrBase64Encoded(string(body))
return strings.Split(links, "\n")
}
+6 -5
View File
@@ -6,13 +6,14 @@ import (
"io"
"net"
"net/http"
"s-ui/config"
"s-ui/logger"
"s-ui/middleware"
"s-ui/network"
"s-ui/service"
"strconv"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/middleware"
"github.com/alireza0/s-ui/network"
"github.com/alireza0/s-ui/service"
"github.com/gin-gonic/gin"
)
+26 -6
View File
@@ -1,8 +1,8 @@
package sub
import (
"s-ui/logger"
"s-ui/service"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/service"
"github.com/gin-gonic/gin"
)
@@ -21,6 +21,7 @@ func NewSubHandler(g *gin.RouterGroup) {
func (s *SubHandler) initRouter(g *gin.RouterGroup) {
g.GET("/:subid", s.subs)
g.HEAD("/:subid", s.subHeaders)
}
func (s *SubHandler) subs(c *gin.Context) {
@@ -49,10 +50,29 @@ func (s *SubHandler) subs(c *gin.Context) {
return
}
}
// Add headers
c.Writer.Header().Set("Subscription-Userinfo", headers[0])
c.Writer.Header().Set("Profile-Update-Interval", headers[1])
c.Writer.Header().Set("Profile-Title", headers[2])
s.addHeaders(c, headers)
c.String(200, *result)
}
func (s *SubHandler) subHeaders(c *gin.Context) {
subId := c.Param("subid")
client, err := s.SubService.getClientBySubId(subId)
if err != nil {
logger.Error(err)
c.String(400, "Error!")
return
}
headers := s.SubService.getClientHeaders(client)
s.addHeaders(c, headers)
c.Status(200)
}
func (s *SubHandler) addHeaders(c *gin.Context, headers []string) {
c.Writer.Header().Set("Subscription-Userinfo", headers[0])
c.Writer.Header().Set("Profile-Update-Interval", headers[1])
c.Writer.Header().Set("Profile-Title", headers[2])
}
+22 -9
View File
@@ -3,12 +3,13 @@ package sub
import (
"encoding/base64"
"fmt"
"s-ui/database"
"s-ui/database/model"
"s-ui/service"
"s-ui/util"
"strings"
"time"
"github.com/alireza0/s-ui/database"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/service"
"github.com/alireza0/s-ui/util"
)
type SubService struct {
@@ -19,9 +20,7 @@ type SubService struct {
func (s *SubService) GetSubs(subId string) (*string, []string, error) {
var err error
db := database.GetDB()
client := &model.Client{}
err = db.Model(model.Client{}).Where("enable = true and name = ?", subId).First(client).Error
client, err := s.getClientBySubId(subId)
if err != nil {
return nil, nil, err
}
@@ -35,8 +34,7 @@ func (s *SubService) GetSubs(subId string) (*string, []string, error) {
linksArray := s.LinkService.GetLinks(&client.Links, "all", clientInfo)
result := strings.Join(linksArray, "\n")
updateInterval, _ := s.SettingService.GetSubUpdates()
headers := util.GetHeaders(client, updateInterval)
headers := s.getClientHeaders(client)
subEncode, _ := s.SettingService.GetSubEncode()
if subEncode {
@@ -46,6 +44,21 @@ func (s *SubService) GetSubs(subId string) (*string, []string, error) {
return &result, headers, nil
}
func (j *SubService) getClientBySubId(subId string) (*model.Client, error) {
db := database.GetDB()
client := &model.Client{}
err := db.Model(model.Client{}).Where("enable = true and name = ?", subId).First(client).Error
if err != nil {
return nil, err
}
return client, nil
}
func (s *SubService) getClientHeaders(client *model.Client) []string {
updateInterval, _ := s.SettingService.GetSubUpdates()
return util.GetHeaders(client, updateInterval)
}
func (s *SubService) getClientInfo(c *model.Client) string {
now := time.Now().Unix()
+2 -1
View File
@@ -3,7 +3,8 @@ package common
import (
"errors"
"fmt"
"s-ui/logger"
"github.com/alireza0/s-ui/logger"
)
func NewErrorf(format string, a ...interface{}) error {
+40 -15
View File
@@ -1,30 +1,55 @@
package common
import (
"math/rand"
crand "crypto/rand"
"math/big"
mrand "math/rand"
"sync"
"time"
)
var (
allSeq []rune
rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
allSeq []rune = []rune{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
}
fallbackRand = mrand.New(mrand.NewSource(time.Now().UnixNano()))
fallbackMu = sync.Mutex{}
)
func init() {
chars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
for _, char := range chars {
allSeq = append(allSeq, char)
}
}
func Random(n int) string {
runes := make([]rune, n)
for i := 0; i < n; i++ {
runes[i] = allSeq[rnd.Intn(len(allSeq))]
if n <= 0 || len(allSeq) == 0 {
return ""
}
return string(runes)
result := make([]rune, n)
maxBig := big.NewInt(int64(len(allSeq)))
for i := 0; i < n; i++ {
num, err := crand.Int(crand.Reader, maxBig)
if err != nil {
// fallback
fallbackMu.Lock()
result[i] = allSeq[fallbackRand.Intn(len(allSeq))]
fallbackMu.Unlock()
continue
}
result[i] = allSeq[int(num.Int64())]
}
return string(result)
}
func RandomInt(n int) int {
return rnd.Intn(n)
if n <= 0 {
return 0
}
max := big.NewInt(int64(n))
result, err := crand.Int(crand.Reader, max)
if err != nil {
// fallback
fallbackMu.Lock()
defer fallbackMu.Unlock()
return fallbackRand.Intn(n)
}
return int(result.Int64())
}
+238 -220
View File
@@ -5,12 +5,18 @@ import (
"encoding/json"
"fmt"
"net/url"
"s-ui/database/model"
"s-ui/util/common"
"strings"
"github.com/alireza0/s-ui/database/model"
"github.com/alireza0/s-ui/util/common"
)
var InboundTypeWithLink = []string{"shadowsocks", "naive", "hysteria", "hysteria2", "anytls", "tuic", "vless", "trojan", "vmess"}
var InboundTypeWithLink = []string{"socks", "http", "mixed", "shadowsocks", "naive", "hysteria", "hysteria2", "anytls", "tuic", "vless", "trojan", "vmess"}
type LinkParam struct {
Key string
Value string
}
func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname string) []string {
inbound, err := i.MarshalFull()
@@ -29,7 +35,9 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
}
var Addrs []map[string]interface{}
json.Unmarshal(i.Addrs, &Addrs)
if err := json.Unmarshal(i.Addrs, &Addrs); err != nil {
return []string{}
}
if len(Addrs) == 0 {
Addrs = append(Addrs, map[string]interface{}{
"server": hostname,
@@ -61,6 +69,15 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
}
switch i.Type {
case "socks":
return socksLink(userConfig["socks"], Addrs)
case "http":
return httpLink(userConfig["http"], Addrs)
case "mixed":
return append(
socksLink(userConfig["socks"], Addrs),
httpLink(userConfig["http"], Addrs)...,
)
case "shadowsocks":
return shadowsocksLink(userConfig, *inbound, Addrs)
case "naive":
@@ -86,8 +103,12 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
func prepareTls(t *model.Tls) map[string]interface{} {
var iTls, oTls map[string]interface{}
json.Unmarshal(t.Client, &oTls)
json.Unmarshal(t.Server, &iTls)
if err := json.Unmarshal(t.Client, &oTls); err != nil {
return nil
}
if err := json.Unmarshal(t.Server, &iTls); err != nil {
return nil
}
for k, v := range iTls {
switch k {
@@ -97,8 +118,8 @@ func prepareTls(t *model.Tls) map[string]interface{} {
reality := v.(map[string]interface{})
clientReality := oTls["reality"].(map[string]interface{})
clientReality["enabled"] = reality["enabled"]
if short_ids, hasSIds := reality["short_id"].([]interface{}); hasSIds && len(short_ids) > 0 {
clientReality["short_id"] = short_ids[common.RandomInt(len(short_ids))]
if shortIDs, hasSIds := reality["short_id"].([]interface{}); hasSIds && len(shortIDs) > 0 {
clientReality["short_id"] = shortIDs[common.RandomInt(len(shortIDs))]
}
oTls["reality"] = clientReality
}
@@ -106,6 +127,26 @@ func prepareTls(t *model.Tls) map[string]interface{} {
return oTls
}
func socksLink(userConfig map[string]interface{}, addrs []map[string]interface{}) []string {
var links []string
for _, addr := range addrs {
links = append(links, fmt.Sprintf("socks5://%s:%s@%s:%d", userConfig["username"], userConfig["password"], addr["server"].(string), uint(addr["server_port"].(float64))))
}
return links
}
func httpLink(userConfig map[string]interface{}, addrs []map[string]interface{}) []string {
var links []string
protocol := "http"
for _, addr := range addrs {
if addr["tls"] != nil {
protocol = "https"
}
links = append(links, fmt.Sprintf("%s://%s:%s@%s:%d", protocol, userConfig["username"], userConfig["password"], addr["server"].(string), uint(addr["server_port"].(float64))))
}
return links
}
func shadowsocksLink(
userConfig map[string]map[string]interface{},
inbound map[string]interface{},
@@ -130,7 +171,7 @@ func shadowsocksLink(
var links []string
for _, addr := range addrs {
port, _ := addr["server_port"].(float64)
links = append(links, fmt.Sprintf("%s@%s:%d", uriBase, addr["server"].(string), uint(port)))
links = append(links, fmt.Sprintf("%s@%s:%.0f#%s", uriBase, addr["server"].(string), port, addr["remark"].(string)))
}
return links
}
@@ -147,31 +188,31 @@ func naiveLink(
var links []string
for _, addr := range addrs {
params := map[string]string{}
params["padding"] = "1"
var params []LinkParam
params = append(params, LinkParam{"padding", "1"})
if tls, ok := addr["tls"].(map[string]interface{}); ok {
if sni, ok := tls["server_name"].(string); ok {
params["peer"] = sni
params = append(params, LinkParam{"peer", sni})
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
params = append(params, LinkParam{"alpn", strings.Join(alpnList, ",")})
}
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["insecure"] = "1"
params = append(params, LinkParam{"insecure", "1"})
}
}
if tfo, ok := inbound["tcp_fast_open"].(bool); ok && tfo {
params["tfo"] = "1"
params = append(params, LinkParam{"tfo", "1"})
} else {
params["tfo"] = "0"
params = append(params, LinkParam{"tfo", "0"})
}
port, _ := addr["server_port"].(float64)
uri := baseUri + toBase64([]byte(fmt.Sprintf("%s:%s@%s:%d", username, password, addr["server"].(string), uint(port))))
uri := baseUri + toBase64([]byte(fmt.Sprintf("%s:%s@%s:%.0f", username, password, addr["server"].(string), port)))
links = append(links, addParams(uri, params, addr["remark"].(string)))
}
return links
@@ -186,42 +227,41 @@ func hysteriaLink(
var links []string
for _, addr := range addrs {
params := map[string]string{}
if upmbps, ok := inbound["up_mbps"].(string); ok {
params["up_mbps"] = upmbps
var params []LinkParam
if upmbps, ok := inbound["up_mbps"].(float64); ok {
params = append(params, LinkParam{"downmbps", fmt.Sprintf("%.0f", upmbps)})
}
if downmbps, ok := inbound["down_mbps"].(string); ok {
params["down_mbps"] = downmbps
if downmbps, ok := inbound["down_mbps"].(float64); ok {
params = append(params, LinkParam{"upmbps", fmt.Sprintf("%.0f", downmbps)})
}
if auth, ok := userConfig["auth_str"].(string); ok {
params["auth"] = auth
params = append(params, LinkParam{"auth", auth})
}
if tls, ok := addr["tls"].(map[string]interface{}); ok {
if sni, ok := tls["server_name"].(string); ok {
params["peer"] = sni
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
}
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["insecure"] = "1"
}
getTlsParams(&params, tls, "insecure")
}
if obfs, ok := inbound["obfs"].(string); ok {
params["obfs"] = obfs
params = append(params, LinkParam{"obfs", obfs})
}
if tfo, ok := inbound["tcp_fast_open"].(bool); ok && tfo {
params["fastopen"] = "1"
params = append(params, LinkParam{"fastopen", "1"})
} else {
params["fastopen"] = "0"
params = append(params, LinkParam{"fastopen", "0"})
}
var outJson map[string]interface{}
if err := json.Unmarshal(inbound["out_json"].(json.RawMessage), &outJson); err != nil {
return []string{} // Handle error
}
if mport, ok := outJson["server_ports"].([]interface{}); ok {
mportList := make([]string, len(mport))
for i, v := range mport {
mportList[i] = v.(string)
}
params = append(params, LinkParam{"mport", strings.Join(mportList, ",")})
}
port, _ := addr["server_port"].(float64)
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
links = append(links, addParams(uri, params, addr["remark"].(string)))
}
@@ -238,44 +278,43 @@ func hysteria2Link(
var links []string
for _, addr := range addrs {
params := map[string]string{}
if upmbps, ok := inbound["up_mbps"].(string); ok {
params["up_mbps"] = upmbps
var params []LinkParam
if upmbps, ok := inbound["up_mbps"].(float64); ok {
params = append(params, LinkParam{"downmbps", fmt.Sprintf("%.0f", upmbps)})
}
if downmbps, ok := inbound["down_mbps"].(string); ok {
params["down_mbps"] = downmbps
if downmbps, ok := inbound["down_mbps"].(float64); ok {
params = append(params, LinkParam{"upmbps", fmt.Sprintf("%.0f", downmbps)})
}
if tls, ok := addr["tls"].(map[string]interface{}); ok {
if sni, ok := tls["server_name"].(string); ok {
params["sni"] = sni
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
}
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["insecure"] = "1"
}
getTlsParams(&params, tls, "insecure")
}
if obfs, ok := inbound["obfs"].(map[string]interface{}); ok {
if obfsType, ok := obfs["type"].(string); ok {
params["obfs"] = obfsType
params = append(params, LinkParam{"obfs", obfsType})
}
if obfsPassword, ok := obfs["password"].(string); ok {
params["obfs-password"] = obfsPassword
params = append(params, LinkParam{"obfs-password", obfsPassword})
}
}
if tfo, ok := inbound["tcp_fast_open"].(bool); ok && tfo {
params["fastopen"] = "1"
params = append(params, LinkParam{"fastopen", "1"})
} else {
params["fastopen"] = "0"
params = append(params, LinkParam{"fastopen", "0"})
}
var outJson map[string]interface{}
if err := json.Unmarshal(inbound["out_json"].(json.RawMessage), &outJson); err != nil {
return []string{} // Handle error
}
if mport, ok := outJson["server_ports"].([]interface{}); ok {
mportList := make([]string, len(mport))
for i, v := range mport {
mportList[i] = v.(string)
}
params = append(params, LinkParam{"mport", strings.Join(mportList, ",")})
}
port, _ := addr["server_port"].(float64)
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
links = append(links, addParams(uri, params, addr["remark"].(string)))
}
@@ -291,25 +330,13 @@ func anytlsLink(
var links []string
for _, addr := range addrs {
params := map[string]string{}
var params []LinkParam
if tls, ok := addr["tls"].(map[string]interface{}); ok {
if sni, ok := tls["server_name"].(string); ok {
params["sni"] = sni
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
}
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["insecure"] = "1"
}
getTlsParams(&params, tls, "insecure")
}
port, _ := addr["server_port"].(float64)
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
links = append(links, addParams(uri, params, addr["remark"].(string)))
}
@@ -327,31 +354,16 @@ func tuicLink(
var links []string
for _, addr := range addrs {
params := map[string]string{}
var params []LinkParam
if tls, ok := addr["tls"].(map[string]interface{}); ok {
if sni, ok := tls["server_name"].(string); ok {
params["sni"] = sni
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
}
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["insecure"] = "1"
}
if disableSni, ok := tls["disable_sni"].(bool); ok && disableSni {
params["disable_sni"] = "1"
}
getTlsParams(&params, tls, "insecure")
}
if congestionControl, ok := inbound["congestion_control"].(string); ok {
params["congestion_control"] = congestionControl
params = append(params, LinkParam{"congestion_control", congestionControl})
}
port, _ := addr["server_port"].(float64)
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
links = append(links, addParams(uri, params, addr["remark"].(string)))
}
@@ -368,41 +380,16 @@ func vlessLink(
var links []string
for _, addr := range addrs {
params := baseParams
params := make([]LinkParam, len(baseParams))
copy(params, baseParams)
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
params["security"] = "reality"
if pbk, ok := reality["public_key"].(string); ok {
params["pbk"] = pbk
}
if sid, ok := reality["short_id"].(string); ok {
params["sid"] = sid
}
} else {
params["security"] = "tls"
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["allowInsecure"] = "1"
}
}
getTlsParams(&params, tls, "allowInsecure")
if flow, ok := userConfig["flow"].(string); ok {
params["flow"] = flow
}
if utls, ok := tls["utls"].(map[string]interface{}); ok {
params["fp"], _ = utls["fingerprint"].(string)
}
if sni, ok := tls["server_name"].(string); ok {
params["sni"] = sni
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
params = append(params, LinkParam{"flow", flow})
}
}
port, _ := addr["server_port"].(float64)
uri := fmt.Sprintf("vless://%s@%s:%d", uuid, addr["server"].(string), uint(port))
uri := fmt.Sprintf("vless://%s@%s:%.0f", uuid, addr["server"].(string), port)
uri = addParams(uri, params, addr["remark"].(string))
links = append(links, uri)
}
@@ -419,38 +406,13 @@ func trojanLink(
var links []string
for _, addr := range addrs {
params := baseParams
params := make([]LinkParam, len(baseParams))
copy(params, baseParams)
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
params["security"] = "reality"
if pbk, ok := reality["public_key"].(string); ok {
params["pbk"] = pbk
}
if sid, ok := reality["short_id"].(string); ok {
params["sid"] = sid
}
} else {
params["security"] = "tls"
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["allowInsecure"] = "1"
}
}
if utls, ok := tls["utls"].(map[string]interface{}); ok {
params["fp"], _ = utls["fingerprint"].(string)
}
if sni, ok := tls["server_name"].(string); ok {
params["sni"] = sni
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
}
getTlsParams(&params, tls, "allowInsecure")
}
port, _ := addr["server_port"].(float64)
uri := fmt.Sprintf("trojan://%s@%s:%d", password, addr["server"].(string), uint(port))
uri := fmt.Sprintf("trojan://%s@%s:%.0f", password, addr["server"].(string), port)
uri = addParams(uri, params, addr["remark"].(string))
links = append(links, uri)
}
@@ -464,51 +426,58 @@ func vmessLink(
addrs []map[string]interface{}) []string {
uuid, _ := userConfig["uuid"].(string)
trasportParams := getTransportParams(inbound["transport"])
transportParams := getTransportParams(inbound["transport"])
var links []string
baseParams := map[string]interface{}{
"v": 2,
"v": "2",
"id": uuid,
"aid": 0,
}
if trasportParams["type"] == "http" || trasportParams["type"] == "tcp" {
var net, typ, host, path string
for _, p := range transportParams {
switch p.Key {
case "type":
net = p.Value
case "host":
host = p.Value
case "path":
path = p.Value
}
}
if net == "http" || net == "tcp" {
baseParams["net"] = "tcp"
if trasportParams["type"] == "http" {
baseParams["type"] = "http"
if net == "http" {
typ = "http"
}
} else {
baseParams["net"] = trasportParams["type"]
baseParams["net"] = net
}
for _, addr := range addrs {
obj := baseParams
obj["add"], _ = addr["server"].(string)
port, _ := addr["server_port"].(float64)
obj["port"] = uint(port)
obj["ps"], _ = addr["remark"].(string)
if trasportParams["host"] != "" {
obj["host"] = trasportParams["host"]
}
if trasportParams["path"] != "" {
obj["path"] = trasportParams["path"]
}
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
obj["tls"] = "tls"
if insecure, ok := tls["insecure"].(bool); ok && insecure {
obj["allowInsecure"] = 1
}
if sni, ok := tls["server_name"].(string); ok {
obj["sni"] = sni
}
if utls, ok := tls["utls"].(map[string]interface{}); ok {
obj["fp"], _ = utls["fingerprint"].(string)
}
} else {
obj["tls"] = "none"
obj := make(map[string]interface{})
for k, v := range baseParams {
obj[k] = v
}
jsonStr, _ := json.MarshalIndent(obj, "", " ")
obj["add"], _ = addr["server"].(string)
port, _ := addr["server_port"].(float64)
obj["port"] = fmt.Sprintf("%.0f", port)
obj["ps"], _ = addr["remark"].(string)
if typ != "" {
obj["type"] = typ
}
if host != "" {
obj["host"] = host
}
if path != "" {
obj["path"] = path
}
populateVmessTlsParams(obj, addr["tls"])
jsonStr, _ := json.Marshal(obj)
uri := fmt.Sprintf("vmess://%s", toBase64(jsonStr))
links = append(links, uri)
@@ -516,82 +485,131 @@ func vmessLink(
return links
}
func toBase64(d []byte) string {
return base64.StdEncoding.EncodeToString([]byte(d))
func populateVmessTlsParams(obj map[string]interface{}, tlsConfig interface{}) {
if tlsMap, ok := tlsConfig.(map[string]interface{}); ok && tlsMap["enabled"].(bool) {
obj["tls"] = "tls"
var tlsParams []LinkParam
getTlsParams(&tlsParams, tlsMap, "allowInsecure")
for _, p := range tlsParams {
switch p.Key {
case "security":
// ignore, as "tls" is already set
case "allowInsecure":
obj["allowInsecure"] = 1
case "sni":
obj["sni"] = p.Value
case "fp":
obj["fp"] = p.Value
case "alpn":
obj["alpn"] = p.Value
}
}
} else {
obj["tls"] = "none"
}
}
func addParams(uri string, params map[string]string, remark string) string {
func toBase64(d []byte) string {
return base64.StdEncoding.EncodeToString(d)
}
func addParams(uri string, params []LinkParam, remark string) string {
URL, _ := url.Parse(uri)
q := URL.Query()
for k, v := range params {
q.Add(k, v)
var q []string
for _, p := range params {
switch p.Key {
case "mport", "alpn":
q = append(q, fmt.Sprintf("%s=%s", p.Key, p.Value))
default:
q = append(q, fmt.Sprintf("%s=%s", p.Key, url.QueryEscape(p.Value)))
}
}
URL.RawQuery = q.Encode()
URL.RawQuery = strings.Join(q, "&")
URL.Fragment = remark
return URL.String()
}
func getTransportParams(t interface{}) map[string]string {
params := map[string]string{}
func getTransportParams(t interface{}) []LinkParam {
var params []LinkParam
trasport, _ := t.(map[string]interface{})
if transportType, ok := trasport["type"].(string); ok {
params["type"] = transportType
var transportType string
if tt, ok := trasport["type"].(string); ok {
transportType = tt
} else {
params["type"] = "tcp"
transportType = "tcp"
}
params = append(params, LinkParam{"type", transportType})
if transportType == "tcp" {
return params
}
switch params["type"] {
switch transportType {
case "http":
if host, ok := trasport["host"].([]interface{}); ok {
var hosts []string
for _, v := range host {
hosts = append(hosts, v.(string))
}
params["host"] = strings.Join(hosts, ",")
params = append(params, LinkParam{"host", strings.Join(hosts, ",")})
}
if path, ok := trasport["path"].(string); ok {
params["path"] = path
params = append(params, LinkParam{"path", path})
}
case "ws":
if path, ok := trasport["path"].(string); ok {
params["path"] = path
params = append(params, LinkParam{"path", path})
}
if headers, ok := trasport["headers"].(map[string]interface{}); ok {
if host, ok := headers["Host"].(string); ok {
params["host"] = host
params = append(params, LinkParam{"host", host})
}
}
case "grpc":
if serviceName, ok := trasport["service_name"].(string); ok {
params["serviceName"] = serviceName
params = append(params, LinkParam{"serviceName", serviceName})
}
case "httpupgrade":
if host, ok := trasport["host"].(string); ok {
params["host"] = host
params = append(params, LinkParam{"host", host})
}
if path, ok := trasport["path"].(string); ok {
params["path"] = path
params = append(params, LinkParam{"path", path})
}
}
return params
}
func getTlsParams(t interface{}) map[string]string {
params := map[string]string{}
if tls, hasTls := t.(map[string]interface{}); hasTls {
if sni, ok := tls["server_name"].(string); ok {
params["sni"] = sni
func getTlsParams(params *[]LinkParam, tls map[string]interface{}, insecureKey string) {
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
*params = append(*params, LinkParam{"security", "reality"})
if pbk, ok := reality["public_key"].(string); ok {
*params = append(*params, LinkParam{"pbk", pbk})
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
params["alpn"] = strings.Join(alpnList, ",")
if sid, ok := reality["short_id"].(string); ok {
*params = append(*params, LinkParam{"sid", sid})
}
} else {
*params = append(*params, LinkParam{"security", "tls"})
if insecure, ok := tls["insecure"].(bool); ok && insecure {
params["insecure"] = "1"
*params = append(*params, LinkParam{insecureKey, "1"})
}
if disableSni, ok := tls["disable_sni"].(bool); ok && disableSni {
*params = append(*params, LinkParam{"disable_sni", "1"})
}
}
return params
if utls, ok := tls["utls"].(map[string]interface{}); ok {
if fingerprint, ok := utls["fingerprint"].(string); ok {
*params = append(*params, LinkParam{"fp", fingerprint})
}
}
if sni, ok := tls["server_name"].(string); ok {
*params = append(*params, LinkParam{"sni", sni})
}
if alpn, ok := tls["alpn"].([]interface{}); ok {
alpnList := make([]string, len(alpn))
for i, v := range alpn {
alpnList[i] = v.(string)
}
*params = append(*params, LinkParam{"alpn", strings.Join(alpnList, ",")})
}
}
+49 -62
View File
@@ -5,9 +5,10 @@ import (
"fmt"
"net"
"net/url"
"s-ui/util/common"
"strconv"
"strings"
"github.com/alireza0/s-ui/util/common"
)
func GetOutbound(uri string, i int) (*map[string]interface{}, string, error) {
@@ -114,9 +115,9 @@ func vmess(data string, i int) (*map[string]interface{}, string, error) {
if i > 0 {
tag = fmt.Sprintf("%d.%s", i, tag)
}
alter_id, ok := dataJson["aid"].(int)
if !ok {
alter_id = 0
alter_id := 0
if aid, ok := dataJson["aid"].(float64); ok {
alter_id = int(aid)
}
vmess := map[string]interface{}{
"type": "vmess",
@@ -199,17 +200,9 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
port, _ = strconv.Atoi(portStr)
}
tls := map[string]interface{}{
"enabled": true,
"server_name": query.Get("peer"),
}
alpn := query.Get("alpn")
insecure := query.Get("insecure")
if len(alpn) > 0 {
tls["alpn"] = strings.Split(alpn, ",")
}
if insecure == "1" || insecure == "true" {
tls["insecure"] = true
security := query.Get("security")
if len(security) == 0 {
security = "tls"
}
tag := u.Fragment
@@ -223,7 +216,7 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
"server_port": port,
"obfs": query.Get("obfsParam"),
"auth_str": query.Get("auth"),
"tls": tls,
"tls": getTls(security, &query),
}
down, _ := strconv.Atoi(query.Get("downmbps"))
up, _ := strconv.Atoi(query.Get("upmbps"))
@@ -252,17 +245,9 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
port, _ = strconv.Atoi(portStr)
}
tls := map[string]interface{}{
"enabled": true,
"server_name": query.Get("sni"),
}
alpn := query.Get("alpn")
insecure := query.Get("insecure")
if len(alpn) > 0 {
tls["alpn"] = strings.Split(alpn, ",")
}
if insecure == "1" || insecure == "true" {
tls["insecure"] = true
security := query.Get("security")
if len(security) == 0 {
security = "tls"
}
tag := u.Fragment
@@ -275,11 +260,13 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
"server": host,
"server_port": port,
"password": u.User.Username(),
"tls": tls,
"tls": getTls(security, &query),
}
down, _ := strconv.Atoi(query.Get("downmbps"))
up, _ := strconv.Atoi(query.Get("upmbps"))
obfs := query.Get("obfs")
mport := query.Get("mport")
fastopen := query.Get("fastopen")
if down > 0 {
hy2["down_mbps"] = down
}
@@ -292,6 +279,12 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
"password": query.Get("obfs-password"),
}
}
if len(mport) > 0 {
hy2["server_ports"] = strings.Split(mport, ",")
}
if fastopen == "1" || fastopen == "true" {
hy2["fastopen"] = true
}
return &hy2, tag, nil
}
@@ -303,17 +296,9 @@ func anytls(u *url.URL, i int) (*map[string]interface{}, string, error) {
port, _ = strconv.Atoi(portStr)
}
tls := map[string]interface{}{
"enabled": true,
"server_name": query.Get("sni"),
}
alpn := query.Get("alpn")
insecure := query.Get("insecure")
if len(alpn) > 0 {
tls["alpn"] = strings.Split(alpn, ",")
}
if insecure == "1" || insecure == "true" {
tls["insecure"] = true
security := query.Get("security")
if len(security) == 0 {
security = "tls"
}
tag := u.Fragment
@@ -326,7 +311,7 @@ func anytls(u *url.URL, i int) (*map[string]interface{}, string, error) {
"server": host,
"server_port": port,
"password": u.User.Username(),
"tls": tls,
"tls": getTls(security, &query),
}
return &anytls, tag, nil
}
@@ -339,21 +324,9 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
port, _ = strconv.Atoi(portStr)
}
tls := map[string]interface{}{
"enabled": true,
"server_name": query.Get("sni"),
}
alpn := query.Get("alpn")
insecure := query.Get("allow_insecure")
disable_sni := query.Get("disable_sni")
if len(alpn) > 0 {
tls["alpn"] = strings.Split(alpn, ",")
}
if insecure == "1" || insecure == "true" {
tls["insecure"] = true
}
if disable_sni == "1" || disable_sni == "true" {
tls["disable_sni"] = true
security := query.Get("security")
if len(security) == 0 {
security = "tls"
}
tag := u.Fragment
@@ -370,7 +343,7 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
"password": password,
"congestion_control": query.Get("congestion_control"),
"udp_relay_mode": query.Get("udp_relay_mode"),
"tls": tls,
"tls": getTls(security, &query),
}
return &tuic, tag, nil
}
@@ -435,7 +408,7 @@ func ss(u *url.URL, i int) (*map[string]interface{}, string, error) {
return &ss, tag, nil
}
func getTransport(tp_type string, q *url.Values) *map[string]interface{} {
func getTransport(tp_type string, q *url.Values) map[string]interface{} {
transport := map[string]interface{}{}
tp_host := q.Get("host")
tp_path := q.Get("path")
@@ -472,15 +445,18 @@ func getTransport(tp_type string, q *url.Values) *map[string]interface{} {
transport["path"] = tp_path
transport["host"] = tp_host
}
return &transport
return transport
}
func getTls(security string, q *url.Values) *map[string]interface{} {
func getTls(security string, q *url.Values) map[string]interface{} {
tls := map[string]interface{}{}
tls_fp := q.Get("fp")
tls_sni := q.Get("sni")
tls_insecure := q.Get("allowInsecure")
tls_allow_insecure := q.Get("allowInsecure")
tls_insecure := q.Get("insecure")
tls_alpn := q.Get("alpn")
tls_ech := q.Get("ech")
disable_sni := q.Get("disable_sni")
switch security {
case "tls":
tls["enabled"] = true
@@ -498,7 +474,7 @@ func getTls(security string, q *url.Values) *map[string]interface{} {
if len(tls_alpn) > 0 {
tls["alpn"] = strings.Split(tls_alpn, ",")
}
if tls_insecure == "1" || tls_insecure == "true" {
if tls_insecure == "1" || tls_insecure == "true" || tls_allow_insecure == "1" || tls_allow_insecure == "true" {
tls["insecure"] = true
}
if len(tls_fp) > 0 {
@@ -507,5 +483,16 @@ func getTls(security string, q *url.Values) *map[string]interface{} {
"fingerprint": tls_fp,
}
}
return &tls
if len(tls_ech) > 0 {
tls["ech"] = map[string]interface{}{
"enabled": true,
"config": []string{
tls_ech,
},
}
}
if disable_sni == "1" || disable_sni == "true" {
tls["disable_sni"] = true
}
return tls
}
+5 -4
View File
@@ -2,8 +2,10 @@ package util
import (
"encoding/json"
"math/rand"
"s-ui/database/model"
"github.com/alireza0/s-ui/util/common"
"github.com/alireza0/s-ui/database/model"
)
// Fill Inbound's out_json
@@ -42,7 +44,6 @@ func FillOutJson(i *model.Inbound, hostname string) error {
case "http", "socks", "mixed", "anytls":
case "shadowsocks":
shadowsocksOut(&outJson, *inbound)
return nil
case "shadowtls":
shadowTlsOut(&outJson, *inbound)
case "hysteria":
@@ -108,7 +109,7 @@ func addTls(out *map[string]interface{}, tls *model.Tls) {
realityConfig := tlsConfig["reality"].(map[string]interface{})
realityConfig["enabled"] = true
if shortIDs, ok := reality["short_id"].([]interface{}); ok && len(shortIDs) > 0 {
realityConfig["short_id"] = shortIDs[rand.Intn(len(shortIDs))]
realityConfig["short_id"] = shortIDs[common.RandomInt(len(shortIDs))]
}
tlsConfig["reality"] = realityConfig
}
+2 -1
View File
@@ -2,7 +2,8 @@ package util
import (
"fmt"
"s-ui/database/model"
"github.com/alireza0/s-ui/database/model"
)
func GetHeaders(client *model.Client, updateInterval int) []string {
+97
View File
@@ -0,0 +1,97 @@
package util
import (
"crypto/tls"
"encoding/json"
"io"
"net/http"
"strings"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/util/common"
)
func GetExternalLink(url string) string {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
response, err := client.Get(url)
if err != nil {
logger.Warning("sub: Error making HTTP request:", err)
return ""
}
defer response.Body.Close()
body, err := io.ReadAll(response.Body)
if err != nil {
logger.Warning("sub: Error reading response body:", err)
return ""
}
data := StrOrBase64Encoded(string(body))
return data
}
func GetExternalSub(url string) ([]map[string]interface{}, error) {
var err error
var result []map[string]interface{}
if len(url) == 0 {
return nil, common.NewError("no url")
}
data := GetExternalLink(url)
if len(data) == 0 {
return nil, common.NewError("no result")
}
// if the data is a JSON object
if strings.HasPrefix(data, "{") && strings.HasSuffix(data, "}") {
var jsonData map[string]interface{}
err = json.Unmarshal([]byte(data), &jsonData)
if err != nil {
logger.Warning("sub: Error unmarshalling JSON:", err)
return nil, err
}
outbounds, ok := jsonData["outbounds"].([]any)
if !ok {
logger.Warning("sub: Error getting outbounds:", err)
return nil, err
}
for _, outbound := range outbounds {
outboundMap, ok := outbound.(map[string]interface{})
if ok && len(outboundMap) > 0 {
oType, _ := outboundMap["type"].(string)
switch oType {
case "urltest":
case "direct":
case "selector":
case "block":
continue
default:
result = append(result, outboundMap)
}
}
}
if len(result) == 0 {
return nil, common.NewError("no result")
}
return result, nil
} else {
// if data is a text
links := strings.Split(data, "\n")
for _, link := range links {
linkToJson, _, err := GetOutbound(link, 0)
if err == nil {
result = append(result, *linkToJson)
}
}
}
if len(result) == 0 {
return nil, common.NewError("no result")
}
return result, nil
}
+7 -6
View File
@@ -9,15 +9,16 @@ import (
"io/fs"
"net"
"net/http"
"s-ui/api"
"s-ui/config"
"s-ui/logger"
"s-ui/middleware"
"s-ui/network"
"s-ui/service"
"strconv"
"strings"
"github.com/alireza0/s-ui/api"
"github.com/alireza0/s-ui/config"
"github.com/alireza0/s-ui/logger"
"github.com/alireza0/s-ui/middleware"
"github.com/alireza0/s-ui/network"
"github.com/alireza0/s-ui/service"
"github.com/gin-contrib/gzip"
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
+23
View File
@@ -0,0 +1,23 @@
# Windows Files
This directory contains all Windows-specific files for S-UI.
## Available Files:
- **s-ui-windows.xml**: Windows Service configuration
- **install-windows.bat**: Installation script
- **s-ui-windows.bat**: Control panel
- **uninstall-windows.bat**: Uninstallation script
- **build-windows.bat**: Simple build script for CMD
- **build-windows.ps1**: Advanced build script for PowerShell
## Usage:
To install S-UI on Windows:
1. Run `install-windows.bat` as Administrator
2. Follow the installation wizard
3. Use `s-ui-windows.bat` for management
To build from source:
- With CMD: `build-windows.bat`
- With PowerShell: `.\build-windows.ps1`
+73
View File
@@ -0,0 +1,73 @@
@echo off
setlocal enabledelayedexpansion
echo Building S-UI for Windows...
cd /d "%~dp0"
REM Check if Go is installed
go version >nul 2>&1
if errorlevel 1 (
echo Error: Go is not installed or not in PATH
echo Please install Go from https://golang.org/dl/
pause
exit /b 1
)
REM Check if Node.js is installed
node --version >nul 2>&1
if errorlevel 1 (
echo Error: Node.js is not installed or not in PATH
echo Please install Node.js from https://nodejs.org/
pause
exit /b 1
)
echo Building frontend...
cd frontend
call npm install
if errorlevel 1 (
echo Error: Failed to install frontend dependencies
pause
exit /b 1
)
call npm run build
if errorlevel 1 (
echo Error: Failed to build frontend
pause
exit /b 1
)
cd ..
echo Creating web/html directory...
if not exist "web\html" mkdir "web\html"
echo Copying frontend build files...
xcopy "frontend\dist\*" "web\html\" /E /Y /Q
echo Building backend...
set CGO_ENABLED=1
set GOOS=windows
set GOARCH=amd64
REM Try to build with CGO first
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
if errorlevel 1 (
echo Warning: CGO build failed, trying without CGO...
set CGO_ENABLED=0
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
if errorlevel 1 (
echo Error: Failed to build backend
pause
exit /b 1
)
echo Built without CGO (some features may be limited)
) else (
echo Built with CGO
)
echo Build completed successfully!
echo Output: sui.exe
pause
+138
View File
@@ -0,0 +1,138 @@
# PowerShell script for building S-UI on Windows
param(
[string]$Architecture = "amd64",
[switch]$NoCGO,
[switch]$Help
)
if ($Help) {
Write-Host "Usage: .\build-windows.ps1 [-Architecture <arch>] [-NoCGO] [-Help]"
Write-Host "Architectures: amd64, 386, arm64"
Write-Host "Examples:"
Write-Host " .\build-windows.ps1 # Build for amd64 with CGO"
Write-Host " .\build-windows.ps1 -Architecture 386 # Build for 32-bit Windows"
Write-Host " .\build-windows.ps1 -NoCGO # Build without CGO"
exit 0
}
Write-Host "Building S-UI for Windows ($Architecture)..." -ForegroundColor Green
# Check if Go is installed
try {
$goVersion = go version 2>$null
if ($LASTEXITCODE -ne 0) {
throw "Go not found"
}
Write-Host "Go version: $goVersion" -ForegroundColor Green
} catch {
Write-Host "Error: Go is not installed or not in PATH" -ForegroundColor Red
Write-Host "Please install Go from https://golang.org/dl/" -ForegroundColor Yellow
Read-Host "Press Enter to exit"
exit 1
}
# Check if Node.js is installed
try {
$nodeVersion = node --version 2>$null
if ($LASTEXITCODE -ne 0) {
throw "Node.js not found"
}
Write-Host "Node.js version: $nodeVersion" -ForegroundColor Green
} catch {
Write-Host "Error: Node.js is not installed or not in PATH" -ForegroundColor Red
Write-Host "Please install Node.js from https://nodejs.org/" -ForegroundColor Yellow
Read-Host "Press Enter to exit"
exit 1
}
# Build frontend
Write-Host "Building frontend..." -ForegroundColor Yellow
Push-Location frontend
try {
Write-Host "Installing dependencies..." -ForegroundColor Cyan
npm install
if ($LASTEXITCODE -ne 0) {
throw "Failed to install frontend dependencies"
}
Write-Host "Building frontend..." -ForegroundColor Cyan
npm run build
if ($LASTEXITCODE -ne 0) {
throw "Failed to build frontend"
}
} catch {
Write-Host "Error: $_" -ForegroundColor Red
Pop-Location
Read-Host "Press Enter to exit"
exit 1
}
Pop-Location
# Create web/html directory
Write-Host "Creating web/html directory..." -ForegroundColor Yellow
if (!(Test-Path "web\html")) {
New-Item -ItemType Directory -Path "web\html" -Force | Out-Null
}
# Copy frontend build files
Write-Host "Copying frontend build files..." -ForegroundColor Yellow
Copy-Item "frontend\dist\*" "web\html\" -Recurse -Force
# Build backend
Write-Host "Building backend..." -ForegroundColor Yellow
# Set environment variables
$env:GOOS = "windows"
$env:GOARCH = $Architecture
if ($NoCGO) {
$env:CGO_ENABLED = "0"
Write-Host "Building without CGO..." -ForegroundColor Yellow
} else {
$env:CGO_ENABLED = "1"
Write-Host "Building with CGO..." -ForegroundColor Yellow
}
# Build command
$buildCmd = "go build -ldflags `"-w -s`" -tags `"with_quic,with_grpc,with_utls,with_acme,with_gvisor`" -o sui.exe main.go"
try {
Invoke-Expression $buildCmd
if ($LASTEXITCODE -ne 0) {
if (!$NoCGO) {
Write-Host "CGO build failed, trying without CGO..." -ForegroundColor Yellow
$env:CGO_ENABLED = "0"
Invoke-Expression $buildCmd
if ($LASTEXITCODE -ne 0) {
throw "Failed to build backend even without CGO"
}
Write-Host "Built without CGO (some features may be limited)" -ForegroundColor Yellow
} else {
throw "Failed to build backend"
}
} else {
if ($env:CGO_ENABLED -eq "1") {
Write-Host "Built successfully with CGO" -ForegroundColor Green
} else {
Write-Host "Built successfully without CGO" -ForegroundColor Green
}
}
} catch {
Write-Host "Error: $_" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit 1
}
Write-Host "Build completed successfully!" -ForegroundColor Green
Write-Host "Output: sui.exe" -ForegroundColor Green
# Show file info
if (Test-Path "sui.exe") {
$fileInfo = Get-Item "sui.exe"
Write-Host "File size: $([math]::Round($fileInfo.Length / 1MB, 2)) MB" -ForegroundColor Cyan
Write-Host "Created: $($fileInfo.CreationTime)" -ForegroundColor Cyan
}
Read-Host "Press Enter to exit"
+195
View File
@@ -0,0 +1,195 @@
@echo off
setlocal enabledelayedexpansion
echo ========================================
echo S-UI Windows Installer
echo ========================================
REM Check if running as Administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Error: This script must be run as Administrator
echo Right-click on this file and select "Run as administrator"
pause
exit /b 1
)
cd /d "%~dp0"
REM Set installation directory
set "INSTALL_DIR=C:\Program Files\s-ui"
set "SERVICE_NAME=s-ui"
echo Installing S-UI to: %INSTALL_DIR%
REM Create installation directory
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
if not exist "%INSTALL_DIR%\db" mkdir "%INSTALL_DIR%\db"
if not exist "%INSTALL_DIR%\logs" mkdir "%INSTALL_DIR%\logs"
if not exist "%INSTALL_DIR%\cert" mkdir "%INSTALL_DIR%\cert"
REM Copy files
echo Copying files...
copy "sui.exe" "%INSTALL_DIR%\" >nul
copy "s-ui-windows.xml" "%INSTALL_DIR%\" >nul
copy "s-ui-windows.bat" "%INSTALL_DIR%\" >nul
REM Check if WinSW is available
set "WINSW_PATH=%INSTALL_DIR%\winsw.exe"
if not exist "%WINSW_PATH%" (
echo Downloading WinSW...
powershell -Command "& {Invoke-WebRequest -Uri 'https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe' -OutFile '%WINSW_PATH%'}"
if exist "%WINSW_PATH%" (
echo WinSW downloaded successfully
) else (
echo Warning: Failed to download WinSW. Service installation will be skipped.
echo You can manually download WinSW from: https://github.com/winsw/winsw/releases
)
)
REM Install Windows Service
if exist "%WINSW_PATH%" (
echo Installing Windows Service...
cd /d "%INSTALL_DIR%"
copy "winsw.exe" "s-ui-service.exe" >nul
copy "s-ui-windows.xml" "s-ui-service.xml" >nul
REM Install service
s-ui-service.exe install
if %errorLevel% equ 0 (
echo Service installed successfully
) else (
echo Warning: Failed to install service. You can install it manually later.
)
)
REM Run migration
echo Running database migration...
cd /d "%INSTALL_DIR%"
sui.exe migrate
if %errorLevel% equ 0 (
echo Migration completed successfully
) else (
echo Warning: Migration failed or database is new
)
REM Get network configuration
echo.
echo ========================================
echo Network Configuration
echo ========================================
REM Get local IP addresses
echo Available IP addresses:
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do (
echo %%i
)
REM Get panel configuration
echo.
set /p panel_port="Enter panel port (default: 2095): "
if "%panel_port%"=="" set "panel_port=2095"
set /p panel_path="Enter panel path (default: /app/): "
if "%panel_path%"=="" set "panel_path=/app/"
set /p sub_port="Enter subscription port (default: 2096): "
if "%sub_port%"=="" set "sub_port=2096"
set /p sub_path="Enter subscription path (default: /sub/): "
if "%sub_path%"=="" set "sub_path=/sub/"
REM Apply settings
echo.
echo Applying settings...
cd /d "%INSTALL_DIR%"
sui.exe setting -port %panel_port% -path "%panel_path%" -subPort %sub_port% -subPath "%sub_path%"
REM Get admin credentials
echo.
echo ========================================
echo Admin Configuration
echo ========================================
set /p admin_username="Enter admin username (default: admin): "
if "%admin_username%"=="" set "admin_username=admin"
set /p admin_password="Enter admin password: "
if "%admin_password%"=="" (
echo Error: Password cannot be empty
pause
exit /b 1
)
REM Set admin credentials
echo Setting admin credentials...
sui.exe admin -username "%admin_username%" -password "%admin_password%"
REM Start service
echo Starting S-UI service...
net start %SERVICE_NAME%
if %errorLevel% equ 0 (
echo Service started successfully
) else (
echo Warning: Failed to start service. You can start it manually later.
)
REM Create desktop shortcut
echo Creating desktop shortcut...
set "DESKTOP=%USERPROFILE%\Desktop"
if exist "%DESKTOP%" (
powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%DESKTOP%\S-UI.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\s-ui-windows.bat'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = 'S-UI Control Panel'; $Shortcut.Save()}"
echo Desktop shortcut created
)
REM Create Start Menu shortcut
echo Creating Start Menu shortcut...
set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs"
if exist "%START_MENU%" (
if not exist "%START_MENU%\S-UI" mkdir "%START_MENU%\S-UI"
powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%START_MENU%\S-UI\S-UI Control Panel.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\s-ui-windows.bat'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = 'S-UI Control Panel'; $Shortcut.Save()}"
echo Start Menu shortcut created
)
REM Set permissions
echo Setting permissions...
icacls "%INSTALL_DIR%" /grant "Users:(OI)(CI)RX" /T >nul
icacls "%INSTALL_DIR%\db" /grant "Users:(OI)(CI)F" /T >nul
icacls "%INSTALL_DIR%\logs" /grant "Users:(OI)(CI)F" /T >nul
REM Create environment variable
echo Setting environment variable...
setx SUI_HOME "%INSTALL_DIR%" /M >nul
REM Show final configuration
echo.
echo ========================================
echo Installation completed successfully!
echo ========================================
echo.
echo S-UI has been installed to: %INSTALL_DIR%
echo.
echo Configuration:
echo Panel Port: %panel_port%
echo Panel Path: %panel_path%
echo Subscription Port: %sub_port%
echo Subscription Path: %sub_path%
echo Admin Username: %admin_username%
echo.
echo Access URLs:
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do (
set "ip=%%i"
set "ip=!ip: =!"
echo Panel: http://!ip!:%panel_port%%panel_path%
echo Subscription: http://!ip!:%sub_port%%sub_path%
)
echo.
echo Service name: %SERVICE_NAME%
echo.
echo Useful commands:
echo net start %SERVICE_NAME% - Start the service
echo net stop %SERVICE_NAME% - Stop the service
echo sc query %SERVICE_NAME% - Check service status
echo.
echo You can also use the desktop shortcut or Start Menu item.
echo.
pause
+237
View File
@@ -0,0 +1,237 @@
@echo off
setlocal enabledelayedexpansion
REM S-UI Windows Control Script
REM This script provides a menu-driven interface for managing S-UI on Windows
cd /d "%~dp0"
set "SERVICE_NAME=s-ui"
set "INSTALL_DIR=%SUI_HOME%"
if "%INSTALL_DIR%"=="" set "INSTALL_DIR=C:\Program Files\s-ui"
:menu
cls
echo ========================================
echo S-UI Windows Control Panel
echo ========================================
echo.
echo Current directory: %INSTALL_DIR%
echo.
echo 1. Start S-UI Service
echo 2. Stop S-UI Service
echo 3. Restart S-UI Service
echo 4. Check Service Status
echo 5. View Service Logs
echo 6. Open Panel in Browser
echo 7. Run S-UI Manually
echo 8. Install/Uninstall Service
echo 9. Open Installation Directory
echo 10. Show Configuration
echo 11. Show Access URLs
echo 0. Exit
echo.
echo ========================================
set /p choice="Please select an option [0-11]: "
if "%choice%"=="1" goto start_service
if "%choice%"=="2" goto stop_service
if "%choice%"=="3" goto restart_service
if "%choice%"=="4" goto check_status
if "%choice%"=="5" goto view_logs
if "%choice%"=="6" goto open_panel
if "%choice%"=="7" goto run_manual
if "%choice%"=="8" goto service_management
if "%choice%"=="9" goto open_directory
if "%choice%"=="10" goto show_config
if "%choice%"=="11" goto show_urls
if "%choice%"=="0" goto exit
goto invalid_choice
:start_service
echo Starting S-UI service...
net start %SERVICE_NAME%
if %errorLevel% equ 0 (
echo Service started successfully!
) else (
echo Failed to start service. Error code: %errorLevel%
)
pause
goto menu
:stop_service
echo Stopping S-UI service...
net stop %SERVICE_NAME%
if %errorLevel% equ 0 (
echo Service stopped successfully!
) else (
echo Failed to stop service. Error code: %errorLevel%
)
pause
goto menu
:restart_service
echo Restarting S-UI service...
net stop %SERVICE_NAME% >nul 2>&1
timeout /t 2 /nobreak >nul
net start %SERVICE_NAME%
if %errorLevel% equ 0 (
echo Service restarted successfully!
) else (
echo Failed to restart service. Error code: %errorLevel%
)
pause
goto menu
:check_status
echo Checking S-UI service status...
sc query %SERVICE_NAME%
echo.
echo Service status details:
for /f "tokens=3 delims=: " %%i in ('sc query %SERVICE_NAME% ^| find "STATE"') do (
echo Current state: %%i
)
pause
goto menu
:view_logs
echo Opening S-UI logs...
if exist "%INSTALL_DIR%\logs" (
start "" "%INSTALL_DIR%\logs"
) else (
echo Logs directory not found: %INSTALL_DIR%\logs
)
pause
goto menu
:open_panel
echo Opening S-UI panel in browser...
start http://localhost:2095
echo Panel opened in default browser.
pause
goto menu
:run_manual
echo Running S-UI manually...
if exist "%INSTALL_DIR%\sui.exe" (
cd /d "%INSTALL_DIR%"
echo Starting S-UI in current window...
echo Press Ctrl+C to stop
echo.
sui.exe
) else (
echo S-UI executable not found: %INSTALL_DIR%\sui.exe
echo Please run the installer first.
)
pause
goto menu
:service_management
cls
echo ========================================
echo Service Management
echo ========================================
echo.
echo 1. Install Windows Service
echo 2. Uninstall Windows Service
echo 3. Back to Main Menu
echo.
set /p service_choice="Select option [1-3]: "
if "%service_choice%"=="1" goto install_service
if "%service_choice%"=="2" goto uninstall_service
if "%service_choice%"=="3" goto menu
goto invalid_choice
:install_service
echo Installing Windows Service...
if exist "%INSTALL_DIR%\s-ui-service.exe" (
cd /d "%INSTALL_DIR%"
s-ui-service.exe install
if %errorLevel% equ 0 (
echo Service installed successfully!
echo Starting service...
net start %SERVICE_NAME%
) else (
echo Failed to install service. Error code: %errorLevel%
)
) else (
echo Service wrapper not found. Please run the installer first.
)
pause
goto service_management
:uninstall_service
echo Uninstalling Windows Service...
if exist "%INSTALL_DIR%\s-ui-service.exe" (
cd /d "%INSTALL_DIR%"
net stop %SERVICE_NAME% >nul 2>&1
s-ui-service.exe uninstall
if %errorLevel% equ 0 (
echo Service uninstalled successfully!
) else (
echo Failed to uninstall service. Error code: %errorLevel%
)
) else (
echo Service wrapper not found.
)
pause
goto service_management
:open_directory
echo Opening installation directory...
if exist "%INSTALL_DIR%" (
start "" "%INSTALL_DIR%"
) else (
echo Installation directory not found: %INSTALL_DIR%
)
pause
goto menu
:show_config
echo.
echo ========================================
echo S-UI Configuration
echo ========================================
if exist "%INSTALL_DIR%\sui.exe" (
cd /d "%INSTALL_DIR%"
echo Current settings:
sui.exe setting -show
echo.
echo Admin credentials:
sui.exe admin -show
) else (
echo S-UI executable not found. Please run the installer first.
)
pause
goto menu
:show_urls
echo.
echo ========================================
echo Access URLs
echo ========================================
echo.
echo Local access:
echo Panel: http://localhost:2095
echo Subscription: http://localhost:2096
echo.
echo Network access:
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do (
set "ip=%%i"
set "ip=!ip: =!"
echo Panel: http://!ip!:2095
echo Subscription: http://!ip!:2096
)
echo.
pause
goto menu
:invalid_choice
echo Invalid choice. Please select a valid option.
pause
goto menu
:exit
echo Thank you for using S-UI Windows Control Panel!
exit /b 0
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<service>
<id>s-ui</id>
<name>S-UI Proxy Panel</name>
<description>S-UI is a proxy panel for managing proxy services</description>
<executable>%BASE%\sui.exe</executable>
<arguments></arguments>
<logmode>rotate</logmode>
<logpath>%BASE%\logs</logpath>
<log size="10 m" />
<log keep="10" />
<workingdirectory>%BASE%</workingdirectory>
<env name="SUI_DB_FOLDER" value="db" />
<env name="SUI_DEBUG" value="false" />
<onfailure action="restart" delay="10 sec" />
<onfailure action="restart" delay="20 sec" />
<onfailure action="none" />
<resetfailure>1 hour</resetfailure>
<startmode>Automatic</startmode>
<depend>tcpip</depend>
<depend>netman</depend>
</service>
+102
View File
@@ -0,0 +1,102 @@
@echo off
setlocal enabledelayedexpansion
echo ========================================
echo S-UI Windows Uninstaller
echo ========================================
REM Check if running as Administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo Error: This script must be run as Administrator
echo Right-click on this file and select "Run as administrator"
pause
exit /b 1
)
REM Set installation directory
set "INSTALL_DIR=C:\Program Files\s-ui"
set "SERVICE_NAME=s-ui"
echo Uninstalling S-UI from: %INSTALL_DIR%
REM Stop and remove Windows Service
if exist "%INSTALL_DIR%\s-ui-service.exe" (
echo Stopping and removing Windows Service...
net stop %SERVICE_NAME% >nul 2>&1
cd /d "%INSTALL_DIR%"
s-ui-service.exe uninstall >nul 2>&1
if %errorLevel% equ 0 (
echo Service removed successfully
) else (
echo Warning: Failed to remove service or service was not installed
)
)
REM Remove desktop shortcut
echo Removing desktop shortcut...
set "DESKTOP=%USERPROFILE%\Desktop"
if exist "%DESKTOP%\S-UI.lnk" (
del "%DESKTOP%\S-UI.lnk" >nul 2>&1
echo Desktop shortcut removed
)
REM Remove Start Menu shortcut
echo Removing Start Menu shortcut...
set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs\S-UI"
if exist "%START_MENU%" (
rmdir /s /q "%START_MENU%" >nul 2>&1
echo Start Menu shortcut removed
)
REM Remove environment variable
echo Removing environment variable...
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v SUI_HOME /f >nul 2>&1
REM Ask user if they want to keep data
echo.
set /p keep_data="Do you want to keep your data (database, logs, certificates)? [y/n]: "
if /i "%keep_data%"=="y" (
echo Keeping data files...
REM Remove only executable and service files
if exist "%INSTALL_DIR%\sui.exe" del "%INSTALL_DIR%\sui.exe" >nul 2>&1
if exist "%INSTALL_DIR%\s-ui-service.exe" del "%INSTALL_DIR%\s-ui-service.exe" >nul 2>&1
if exist "%INSTALL_DIR%\s-ui-service.xml" del "%INSTALL_DIR%\s-ui-service.xml" >nul 2>&1
if exist "%INSTALL_DIR%\winsw.exe" del "%INSTALL_DIR%\winsw.exe" >nul 2>&1
if exist "%INSTALL_DIR%\*.bat" del "%INSTALL_DIR%\*.bat" >nul 2>&1
if exist "%INSTALL_DIR%\*.xml" del "%INSTALL_DIR%\*.xml" >nul 2>&1
if exist "%INSTALL_DIR%\*.md" del "%INSTALL_DIR%\*.md" >nul 2>&1
echo Data files preserved in: %INSTALL_DIR%
) else (
echo Removing all files...
REM Remove entire installation directory
if exist "%INSTALL_DIR%" (
rmdir /s /q "%INSTALL_DIR%" >nul 2>&1
if exist "%INSTALL_DIR%" (
echo Warning: Some files could not be removed. Please manually delete: %INSTALL_DIR%
) else (
echo All files removed successfully
)
)
)
REM Remove firewall rules
echo Removing firewall rules...
netsh advfirewall firewall delete rule name="S-UI Panel" >nul 2>&1
netsh advfirewall firewall delete rule name="S-UI Subscription" >nul 2>&1
echo.
echo ========================================
echo Uninstallation completed!
echo ========================================
echo.
echo S-UI has been uninstalled from your system.
echo.
if /i "%keep_data%"=="y" (
echo Your data has been preserved in: %INSTALL_DIR%
echo You can safely delete this directory if you no longer need the data.
)
echo.
echo Thank you for using S-UI!
echo.
pause