mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-09-28 16:15:17 +08:00
Compare commits
122 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
380a8cb3fb | ||
|
fa5ced4660 | ||
|
bac497475f | ||
|
f43b413ed4 | ||
|
356e135ea1 | ||
|
e5c6533c9b | ||
|
8d92cac37d | ||
|
eb7401f6e5 | ||
|
8777501391 | ||
|
2949ea2a89 | ||
|
11f39d0b78 | ||
|
bdc8e267a3 | ||
|
268e9c4e92 | ||
|
b3eb128dbd | ||
|
ce89ea680b | ||
|
fc3b39e09f | ||
|
09160a6891 | ||
|
b059c555cf | ||
|
8ea158a71e | ||
|
3bb71b84b6 | ||
|
afec9af445 | ||
|
eb8d8f4171 | ||
|
632080c1d6 | ||
|
cca9e377c5 | ||
|
8455ef6ed4 | ||
|
ef05b9372a | ||
|
000b041578 | ||
|
57a67ee030 | ||
|
a945c636f4 | ||
|
edf33ba4ae | ||
|
03467e4f06 | ||
|
74782e883b | ||
|
ace4ef08d9 | ||
|
2b24e53c24 | ||
|
a4fd1769a5 | ||
|
0f8877bafc | ||
|
5ee3b3967a | ||
|
3c8d0c6d60 | ||
|
5a331e2125 | ||
|
a0e84312ba | ||
|
098f321343 | ||
|
096b6f8f08 | ||
|
0ff6dbcd78 | ||
|
a650db816c | ||
|
2b8ce3e94a | ||
|
a59e480b61 | ||
|
33139a571d | ||
|
0227c3ee8b | ||
|
8eac03df03 | ||
|
d3d8b2620c | ||
|
bbb9cfda67 | ||
|
ff07c81401 | ||
|
6514657f2f | ||
|
70f3e4302c | ||
|
0e6e4e501c | ||
|
29a3e4bfb3 | ||
|
d73816a811 | ||
|
43a9d31b82 | ||
|
5d4a9c0082 | ||
|
8bd8651fd7 | ||
|
545ddb337f | ||
|
d53ab80848 | ||
|
6c1f29ba3a | ||
|
947339384b | ||
|
0849c6049b | ||
|
936c44e866 | ||
|
02bc75b27a | ||
|
1aa8c83d58 | ||
|
7554876259 | ||
|
2fc3c33880 | ||
|
d45ecbf3b7 | ||
|
54c2d95dd5 | ||
|
7eb8cc2077 | ||
|
fbd799f9f9 | ||
|
f9ff92d73d | ||
|
10a335dc3d | ||
|
cd5652215f | ||
|
b153997cf1 | ||
|
d5046a4f53 | ||
|
b7fbbdc58c | ||
|
39b28f23c0 | ||
|
aa09d928c3 | ||
|
9099aea122 | ||
|
ef3f2aba4c | ||
|
3c015651ef | ||
|
6a598b2570 | ||
|
1f47e3e254 | ||
|
79b7f0c88e | ||
|
289f748543 | ||
|
4f77fd9013 | ||
|
769c304e9a | ||
|
a5d9764d35 | ||
|
f47fbd0252 | ||
|
41278f722d | ||
|
87e50e8e0d | ||
|
5371e4530f | ||
|
9d5f5719d8 | ||
|
911b96cc74 | ||
|
13de601474 | ||
|
56576cb22a | ||
|
70f3e46ef7 | ||
|
1592a1f01b | ||
|
279498e37e | ||
|
9ed8b1a9f1 | ||
|
31a1035267 | ||
|
5731d9a01c | ||
|
c63604aba3 | ||
|
7c3ed549d0 | ||
|
4a33b42726 | ||
|
da92c111e7 | ||
|
634c8c8145 | ||
|
3408198d2d | ||
|
1df0f60ed3 | ||
|
1f5d7d0dab | ||
|
e73504b4b6 | ||
|
2e86547e97 | ||
|
970213f269 | ||
|
ffd68d6c81 | ||
|
3f072242f4 | ||
|
ef1e20a558 | ||
|
42142d95b7 | ||
|
638a99275e |
10
.codecov.yml
10
.codecov.yml
@@ -1,5 +1,7 @@
|
|||||||
ignore:
|
ignore:
|
||||||
- "screenshot"
|
- "^doc"
|
||||||
- "web"
|
- "^home"
|
||||||
- "server/conf"
|
- "^web"
|
||||||
- "server/files"
|
- "^server/conf"
|
||||||
|
- "^server/files"
|
||||||
|
|
||||||
|
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
|
|||||||
issuehunt: # Replace with a single IssueHunt username
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
otechie: # Replace with a single Otechie username
|
otechie: # Replace with a single Otechie username
|
||||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
custom: ['https://github.com/bjdgyc/anylink/blob/main/doc/README.md'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
custom: [ 'https://github.com/bjdgyc/anylink/blob/main/doc/README.md' ] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
|
64
.github/workflows/codeql-analysis.yml
vendored
64
.github/workflows/codeql-analysis.yml
vendored
@@ -12,13 +12,15 @@
|
|||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches: [ "main", "dev" ]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [ "main", "dev" ]
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '32 12 * * 5'
|
- cron: '32 5 * * 1'
|
||||||
|
# push:
|
||||||
|
# branches: [ "main", "dev" ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ "main", "dev" ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
@@ -38,34 +40,34 @@ jobs:
|
|||||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
# By default, queries listed here will override any specified in a config file.
|
# By default, queries listed here will override any specified in a config file.
|
||||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v2
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
# and modify them (or add more) to build your code if your project
|
# and modify them (or add more) to build your code if your project
|
||||||
# uses a compiled language
|
# uses a compiled language
|
||||||
|
|
||||||
#- run: |
|
#- run: |
|
||||||
# make bootstrap
|
# make bootstrap
|
||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
|
48
.github/workflows/go-update.yml
vendored
Normal file
48
.github/workflows/go-update.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
name: go-update
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
# schedule:
|
||||||
|
# - cron: "1 2 * * 5"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
go:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup Go 1.x.y
|
||||||
|
uses: actions/setup-go@main
|
||||||
|
with:
|
||||||
|
go-version: '1.20'
|
||||||
|
stable: true
|
||||||
|
|
||||||
|
- name: Checkout codebase
|
||||||
|
uses: actions/checkout@main
|
||||||
|
|
||||||
|
- name: go
|
||||||
|
run: |
|
||||||
|
cd ./server
|
||||||
|
go mod tidy -compat=1.20
|
||||||
|
#gofmt -w -r 'interface{} -> any' .
|
||||||
|
go get -u
|
||||||
|
go mod download
|
||||||
|
go get -u
|
||||||
|
go mod download
|
||||||
|
|
||||||
|
- name: Git push
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git remote rm origin
|
||||||
|
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ github.repository }}"
|
||||||
|
git gc --aggressive
|
||||||
|
git add --all
|
||||||
|
git commit -m "update go.mod $(date +%Y.%m.%d.%H.%M)"
|
||||||
|
#git push -f -u origin _autoaction
|
||||||
|
git push -u origin _autoaction
|
||||||
|
|
||||||
|
# 删除无用 workflow runs;
|
||||||
|
- name: Delete workflow runs
|
||||||
|
uses: GitRML/delete-workflow-runs@main
|
||||||
|
with:
|
||||||
|
retain_days: 0.1
|
||||||
|
keep_minimum_runs: 1
|
25
.github/workflows/go.yml
vendored
25
.github/workflows/go.yml
vendored
@@ -1,6 +1,8 @@
|
|||||||
name: Go
|
name: Go
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
push:
|
push:
|
||||||
branches: [ "main", "dev" ]
|
branches: [ "main", "dev" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -12,15 +14,15 @@ jobs:
|
|||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: 1.18
|
go-version: '1.20'
|
||||||
id: go
|
go-version-file: 'server/go.mod'
|
||||||
|
cache-dependency-path: 'server/go.sum'
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -32,15 +34,16 @@ jobs:
|
|||||||
cd server
|
cd server
|
||||||
mkdir ui
|
mkdir ui
|
||||||
touch ui/index.html
|
touch ui/index.html
|
||||||
go build -v -o anylink -ldflags "-X main.CommitId=`git rev-parse HEAD`"
|
go build -v -o anylink -trimpath -ldflags "-X main.CommitId=`git rev-parse HEAD`"
|
||||||
./anylink tool -v
|
./anylink tool -v
|
||||||
|
|
||||||
- name: Test coverage
|
- name: Test coverage
|
||||||
run: |
|
run: |
|
||||||
cd server
|
cd server
|
||||||
|
go test ./...
|
||||||
go test -race -coverprofile=coverage.txt -covermode=atomic -v ./...
|
go test -race -coverprofile=coverage.txt -covermode=atomic -v ./...
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage reports to Codecov
|
||||||
run: |
|
uses: codecov/codecov-action@v3
|
||||||
cd server
|
env:
|
||||||
bash <(curl -s https://codecov.io/bash)
|
CODECOV_TOKEN: 28d52fb0-8fc9-460f-95b9-fb84f9138e58
|
||||||
|
98
.github/workflows/release.yml
vendored
Normal file
98
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v0.*"
|
||||||
|
- "v1.*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build:
|
||||||
|
name: build-binary
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
steps:
|
||||||
|
- name: Hello world
|
||||||
|
run: uname -a
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: 'web/yarn.lock'
|
||||||
|
- name: Build web
|
||||||
|
working-directory: web
|
||||||
|
run: |
|
||||||
|
yarn install
|
||||||
|
yarn run build
|
||||||
|
# - uses: actions/setup-go@v4
|
||||||
|
# with:
|
||||||
|
# go-version: '1.20'
|
||||||
|
# cache-dependency-path: 'server/go.sum'
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: bjdgyc
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
logout: true
|
||||||
|
|
||||||
|
- name: Pre bash
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
appVer=`cat version`
|
||||||
|
commitId=`git rev-parse HEAD`
|
||||||
|
echo "APP_VER=$appVer" >> $GITHUB_ENV
|
||||||
|
echo "commitId=$commitId" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
echo $appVer > version_info
|
||||||
|
echo $commitId >> version_info
|
||||||
|
echo $GITHUB_REF >> version_info
|
||||||
|
echo $GITHUB_REF_NAME >> version_info
|
||||||
|
|
||||||
|
#cd server;go mod tidy
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
cache-from: type=gha,scope=anylink
|
||||||
|
cache-to: type=gha,mode=max,scope=anylink
|
||||||
|
context: .
|
||||||
|
file: ./docker/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
#platforms: linux/amd64
|
||||||
|
build-args: |
|
||||||
|
appVer=${{ env.APP_VER }}
|
||||||
|
commitId=${{ env.commitId }}
|
||||||
|
tags: bjdgyc/anylink:${{ env.APP_VER }},bjdgyc/anylink:latest
|
||||||
|
#tags: bjdgyc/anylink:${{ env.APP_VER }}
|
||||||
|
|
||||||
|
- name: Build deploy binary
|
||||||
|
shell: bash
|
||||||
|
run: bash release.sh
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
# https://github.com/ncipollo/release-action
|
||||||
|
# artifacts: bin/release/*
|
||||||
|
# generateReleaseNotes: true
|
||||||
|
# draft: true
|
||||||
|
# https://github.com/softprops/action-gh-release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
#if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
with:
|
||||||
|
tag_name: v${{ env.APP_VER }}
|
||||||
|
files: artifact-dist/*
|
||||||
|
|
||||||
|
# Docker:
|
||||||
|
# name: build-docker
|
8
.gitignore
vendored
8
.gitignore
vendored
@@ -2,4 +2,12 @@
|
|||||||
.idea/
|
.idea/
|
||||||
anylink-deploy
|
anylink-deploy
|
||||||
anylink-deploy.tar.gz
|
anylink-deploy.tar.gz
|
||||||
|
anylink-deploy-*
|
||||||
|
anylink
|
||||||
|
anylink.db
|
||||||
|
|
||||||
|
dist
|
||||||
|
artifact-dist
|
||||||
|
|
||||||
|
anylink_amd64
|
||||||
|
anylink_arm64
|
||||||
|
104
.goreleaser.yaml
Normal file
104
.goreleaser.yaml
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
#https://goreleaser.com/static/schema.json
|
||||||
|
|
||||||
|
# release --skip=publish
|
||||||
|
|
||||||
|
# goreleaser build --skip=validate --clean --debug
|
||||||
|
|
||||||
|
# GOPROXY=https://goproxy.cn
|
||||||
|
|
||||||
|
# docker run -it --rm -v $PWD:/app -v /go:/go -w /app --platform=linux/arm64 golang:alpine3.19
|
||||||
|
|
||||||
|
# docker run -it --rm -v $PWD:/app -v /go:/go -w /app goreleaser/goreleaser-cross build --skip=validate --clean --debug
|
||||||
|
|
||||||
|
# docker run -it --rm -v $PWD:/app -v /go:/go -w /app bjdgyc/dcross goreleaser build --skip=validate --clean --debug
|
||||||
|
|
||||||
|
version: 1
|
||||||
|
|
||||||
|
dist: dist
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- pwd
|
||||||
|
# - cmd: go mod tidy
|
||||||
|
# dir:
|
||||||
|
# "{{ dir .Dist}}"
|
||||||
|
# output: true
|
||||||
|
# - cmd: go generate
|
||||||
|
# dir:
|
||||||
|
# "{{ dir .Dist}}"
|
||||||
|
# output: true
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- id: "build"
|
||||||
|
#main: .
|
||||||
|
dir: ./server
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- cmd: go mod tidy
|
||||||
|
dir: ./server
|
||||||
|
output: true
|
||||||
|
- cmd: go generate
|
||||||
|
dir: ./server
|
||||||
|
output: true
|
||||||
|
# {{- if eq .Arch "amd64" }}CC=x86_64-linux-gnu-gcc CXX=x86_64-linux-gnu-g++{{- end }}
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=1
|
||||||
|
- >-
|
||||||
|
{{- if eq .Os "linux" }}
|
||||||
|
{{- if eq .Arch "amd64" }}CC=x86_64-linux-musl-gcc{{- end }}
|
||||||
|
|
||||||
|
{{- if eq .Arch "arm64" }}CC=aarch64-linux-gnu-gcc{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .Os "darwin" }}
|
||||||
|
{{- if eq .Arch "amd64"}}CC=o64-clang{{- end }}
|
||||||
|
{{- if eq .Arch "arm64"}}CC=oa64-clang{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .Os "windows" }}
|
||||||
|
{{- if eq .Arch "amd64"}}CC=x86_64-w64-mingw32-gcc{{- end }}
|
||||||
|
{{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
#- darwin
|
||||||
|
#- windows
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
#- arm64
|
||||||
|
# https://go.dev/wiki/MinimumRequirements
|
||||||
|
goamd64:
|
||||||
|
- v1
|
||||||
|
command: build
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
- -tags osusergo,netgo,sqlite_omit_load_extension
|
||||||
|
ldflags:
|
||||||
|
# go tool link -help
|
||||||
|
# go tool compile -help
|
||||||
|
# -linkmode external
|
||||||
|
# -extld=$CC
|
||||||
|
# -fpic 作为动态链接库的时候 需要添加
|
||||||
|
|
||||||
|
- -s -w -extldflags '-static' -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=dcross
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- id: "archive1"
|
||||||
|
format: tar.gz
|
||||||
|
# this name template makes the OS and Arch compatible with the results of `uname`.
|
||||||
|
name_template: >-
|
||||||
|
{{ .ProjectName }}_
|
||||||
|
{{- title .Os }}_
|
||||||
|
{{- if eq .Arch "amd64" }}x86_64
|
||||||
|
{{- else if eq .Arch "386" }}i386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||||
|
# use zip for windows archives
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
format: zip
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test:"
|
208
README.md
208
README.md
@@ -3,9 +3,10 @@
|
|||||||
[](https://github.com/bjdgyc/anylink/actions)
|
[](https://github.com/bjdgyc/anylink/actions)
|
||||||
[](https://pkg.go.dev/github.com/bjdgyc/anylink)
|
[](https://pkg.go.dev/github.com/bjdgyc/anylink)
|
||||||
[](https://goreportcard.com/report/github.com/bjdgyc/anylink)
|
[](https://goreportcard.com/report/github.com/bjdgyc/anylink)
|
||||||
[](https://codecov.io/gh/bjdgyc/anylink)
|
[](https://codecov.io/gh/bjdgyc/anylink)
|
||||||

|

|
||||||

|

|
||||||
|

|
||||||
[](https://hub.docker.com/r/bjdgyc/anylink)
|
[](https://hub.docker.com/r/bjdgyc/anylink)
|
||||||

|

|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ AnyLink 基于 [ietf-openconnect](https://tools.ietf.org/html/draft-mavrogiannop
|
|||||||
AnyLink 使用 TLS/DTLS 进行数据加密,因此需要 RSA 或 ECC 证书,可以通过 Let's Encrypt 和 TrustAsia 申请免费的 SSL 证书。
|
AnyLink 使用 TLS/DTLS 进行数据加密,因此需要 RSA 或 ECC 证书,可以通过 Let's Encrypt 和 TrustAsia 申请免费的 SSL 证书。
|
||||||
|
|
||||||
AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18.04、Ubuntu 20.04 测试通过,如需要安装在其他系统,需要服务端支持 tun/tap
|
AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18.04、Ubuntu 20.04 测试通过,如需要安装在其他系统,需要服务端支持 tun/tap
|
||||||
功能、ip 设置命令。
|
功能、ip 设置命令、iptables命令。
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
||||||
@@ -46,43 +47,56 @@ AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18.04、Ubuntu 20.04 测试
|
|||||||
> 没有编程基础的同学建议直接下载 release 包,从下面的地址下载 anylink-deploy.tar.gz
|
> 没有编程基础的同学建议直接下载 release 包,从下面的地址下载 anylink-deploy.tar.gz
|
||||||
>
|
>
|
||||||
> https://github.com/bjdgyc/anylink/releases
|
> https://github.com/bjdgyc/anylink/releases
|
||||||
|
>
|
||||||
|
> https://gitee.com/bjdgyc/anylink/releases
|
||||||
|
>
|
||||||
|
> 如果不会安装,可以提供有偿远程协助服务(200 CNY)。添加QQ(68492170)联系我
|
||||||
|
>
|
||||||
|
> 也可以添加QQ群 咨询群内大佬
|
||||||
|
>
|
||||||
|
> 添加QQ群①(已满): 567510628
|
||||||
|
>
|
||||||
|
> 添加QQ群②: 739072205
|
||||||
|
|
||||||
### 使用问题
|
### 使用问题
|
||||||
|
|
||||||
> 对于测试环境,可以使用 vpn.test.vqilu.cn 绑定host进行测试
|
> 对于测试环境,可以使用 vpn.test.vqilu.cn 绑定host进行测试
|
||||||
>
|
>
|
||||||
> 对于线上环境,必须申请安全的 https 证书,不支持私有证书连接
|
> 对于线上环境,必须申请安全的https证书(跟nginx使用的证书类型一致),不支持私有证书连接
|
||||||
>
|
|
||||||
> 服务端安装 yum install iproute 或者 apt-get install iproute2
|
|
||||||
>
|
|
||||||
> 客户端请使用群共享文件的版本,其他版本没有测试过,不保证使用正常
|
|
||||||
>
|
>
|
||||||
|
> 群共享文件有相关客户端软件下载,其他版本没有测试过,不保证使用正常
|
||||||
|
>
|
||||||
> 其他问题 [前往查看](doc/question.md)
|
> 其他问题 [前往查看](doc/question.md)
|
||||||
>
|
>
|
||||||
> 首次使用,请在浏览器访问 https://域名:443,浏览器提示安全后,在客户端输入 【域名:443】 即可
|
> 默认管理后台访问地址 https://host:8800 或 https://域名:8800 默认账号密码 admin 123456
|
||||||
|
>
|
||||||
|
> 首次使用,请在浏览器访问 https://域名:443 浏览器提示安全后,在客户端输入 【域名:443】 即可
|
||||||
|
|
||||||
### 自行编译安装
|
### 自行编译安装
|
||||||
|
|
||||||
> 需要提前安装好 golang >= 1.19 和 nodejs >= 16.x 和 yarn >= v1.22.x
|
> 需要提前安装好 docker
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/bjdgyc/anylink.git
|
git clone https://github.com/bjdgyc/anylink.git
|
||||||
|
|
||||||
# 编译参考软件版本
|
# docker编译 参考软件版本(不需要安装)
|
||||||
# go 1.20.12
|
# go 1.20.12
|
||||||
# node v16.20.2
|
# node v16.20.2
|
||||||
# yarn 1.22.19
|
# yarn 1.22.19
|
||||||
|
|
||||||
|
|
||||||
cd anylink
|
cd anylink
|
||||||
sh build.sh
|
|
||||||
|
# 编译前端
|
||||||
|
bash build_web.sh
|
||||||
|
# 编译 anylink-deploy 发布文件
|
||||||
|
bash build.sh
|
||||||
|
|
||||||
# 注意使用root权限运行
|
# 注意使用root权限运行
|
||||||
cd anylink-deploy
|
cd anylink-deploy
|
||||||
sudo ./anylink
|
sudo ./anylink
|
||||||
|
|
||||||
# 默认管理后台访问地址
|
# 默认管理后台访问地址
|
||||||
# 注意该host为anylink的内网ip,不能跟客户端请求的ip一样
|
|
||||||
# https://host:8800
|
# https://host:8800
|
||||||
# 默认账号 密码
|
# 默认账号 密码
|
||||||
# admin 123456
|
# admin 123456
|
||||||
@@ -98,10 +112,11 @@ sudo ./anylink
|
|||||||
- [x] 兼容 AnyConnect
|
- [x] 兼容 AnyConnect
|
||||||
- [x] 兼容 OpenConnect
|
- [x] 兼容 OpenConnect
|
||||||
- [x] 基于 tun 设备的 nat 访问模式
|
- [x] 基于 tun 设备的 nat 访问模式
|
||||||
- [x] 基于 tap 设备的桥接访问模式
|
- [x] 基于 tun 设备的桥接访问模式
|
||||||
- [x] 基于 macvtap 设备的桥接访问模式
|
- [x] 基于 macvtap 设备的桥接访问模式
|
||||||
- [x] 支持 [proxy protocol v1&v2](http://www.haproxy.org/download/2.2/doc/proxy-protocol.txt) 协议
|
- [x] 支持 [proxy protocol v1&v2](http://www.haproxy.org/download/2.2/doc/proxy-protocol.txt) 协议
|
||||||
- [x] 用户组支持
|
- [x] 用户组支持
|
||||||
|
- [x] 用户组策略支持
|
||||||
- [x] 多用户支持
|
- [x] 多用户支持
|
||||||
- [x] 用户策略支持
|
- [x] 用户策略支持
|
||||||
- [x] TOTP 令牌支持
|
- [x] TOTP 令牌支持
|
||||||
@@ -109,10 +124,15 @@ sudo ./anylink
|
|||||||
- [x] 流量速率限制
|
- [x] 流量速率限制
|
||||||
- [x] 后台管理界面
|
- [x] 后台管理界面
|
||||||
- [x] 访问权限管理
|
- [x] 访问权限管理
|
||||||
|
- [x] 用户活动审计功能
|
||||||
- [x] IP 访问审计功能
|
- [x] IP 访问审计功能
|
||||||
- [x] 域名动态拆分隧道(域名路由功能)
|
- [x] 域名动态拆分隧道(域名路由功能)
|
||||||
- [x] radius认证支持
|
- [x] radius认证支持
|
||||||
- [x] LDAP认证支持
|
- [x] LDAP认证支持
|
||||||
|
- [x] 空闲链接超时自动断开
|
||||||
|
- [x] 流量压缩功能
|
||||||
|
- [x] 出口 IP 自动放行
|
||||||
|
- [x] 支持多服务的配置区分
|
||||||
- [ ] 基于 ipvtap 设备的桥接访问模式
|
- [ ] 基于 ipvtap 设备的桥接访问模式
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
@@ -120,14 +140,22 @@ sudo ./anylink
|
|||||||
> 示例配置文件内有详细的注释,根据注释填写配置即可。
|
> 示例配置文件内有详细的注释,根据注释填写配置即可。
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
# 查看帮助信息
|
||||||
|
./anylink -h
|
||||||
|
|
||||||
# 生成后台密码
|
# 生成后台密码
|
||||||
./anylink tool -p 123456
|
./anylink tool -p 123456
|
||||||
|
|
||||||
# 生成jwt密钥
|
# 生成jwt密钥
|
||||||
./anylink tool -s
|
./anylink tool -s
|
||||||
|
|
||||||
|
# 查看所有配置项
|
||||||
|
./anylink tool -d
|
||||||
```
|
```
|
||||||
|
|
||||||
> 数据库配置示例
|
> 数据库配置示例
|
||||||
|
>
|
||||||
|
> 数据库表结构自动生成,无需手动导入(请赋予 DDL 权限)
|
||||||
|
|
||||||
| db_type | db_source |
|
| db_type | db_source |
|
||||||
|----------|--------------------------------------------------------|
|
|----------|--------------------------------------------------------|
|
||||||
@@ -139,8 +167,27 @@ sudo ./anylink
|
|||||||
>
|
>
|
||||||
> [conf/server-sample.toml](server/conf/server-sample.toml)
|
> [conf/server-sample.toml](server/conf/server-sample.toml)
|
||||||
|
|
||||||
|
## Upgrade
|
||||||
|
|
||||||
|
> 升级前请备份配置文件`conf`目录 和 数据库,并停止服务
|
||||||
|
>
|
||||||
|
> 使用新版的 `anylink` 二进制文件替换旧版
|
||||||
|
>
|
||||||
|
> 重启服务后,即可完成升级
|
||||||
|
|
||||||
## Setting
|
## Setting
|
||||||
|
|
||||||
|
### 依赖设置
|
||||||
|
|
||||||
|
> 服务端依赖安装:
|
||||||
|
>
|
||||||
|
> centos: yum install iptables iproute
|
||||||
|
>
|
||||||
|
> ubuntu: apt-get install iptables iproute2
|
||||||
|
|
||||||
|
|
||||||
|
### link_mode 设置
|
||||||
|
|
||||||
> 以下参数必须设置其中之一
|
> 以下参数必须设置其中之一
|
||||||
|
|
||||||
网络模式选择,需要配置 `link_mode` 参数,如 `link_mode="tun"`,`link_mode="macvtap"`,`link_mode="tap"(不推荐)` 等参数。
|
网络模式选择,需要配置 `link_mode` 参数,如 `link_mode="tun"`,`link_mode="macvtap"`,`link_mode="tap"(不推荐)` 等参数。
|
||||||
@@ -150,11 +197,13 @@ sudo ./anylink
|
|||||||
IP 层的数据互相转换,性能会有所下降。 如果需要在虚拟机内开启 tap
|
IP 层的数据互相转换,性能会有所下降。 如果需要在虚拟机内开启 tap
|
||||||
模式,请确认虚拟机的网卡开启混杂模式。
|
模式,请确认虚拟机的网卡开启混杂模式。
|
||||||
|
|
||||||
### tun 设置
|
#### tun 设置
|
||||||
|
|
||||||
1. 开启服务器转发
|
1. 开启服务器转发
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
# 新版本支持自动设置ip转发
|
||||||
|
|
||||||
# file: /etc/sysctl.conf
|
# file: /etc/sysctl.conf
|
||||||
net.ipv4.ip_forward = 1
|
net.ipv4.ip_forward = 1
|
||||||
|
|
||||||
@@ -203,20 +252,61 @@ https://cloud.tencent.com/document/product/216/62007
|
|||||||
|
|
||||||
3. 使用 AnyConnect 客户端连接即可
|
3. 使用 AnyConnect 客户端连接即可
|
||||||
|
|
||||||
### macvtap 设置
|
#### 桥接设置
|
||||||
|
|
||||||
1. 设置配置文件
|
1. 设置配置文件
|
||||||
|
|
||||||
> macvtap 设置相对比较简单,只需要配置相应的参数即可。
|
> macvtap 设置相对比较简单,只需要配置相应的参数即可。
|
||||||
|
>
|
||||||
|
> 网络要求:需要网络支持 ARP 传输,可通过 ARP 宣告普通内网 IP。
|
||||||
|
>
|
||||||
|
> 网络限制:云环境下不能使用,网卡mac加白环境不能使用,802.1x认证网络不能使用
|
||||||
|
>
|
||||||
> 以下参数可以通过执行 `ip a` 查看
|
> 以下参数可以通过执行 `ip a` 查看
|
||||||
|
|
||||||
|
|
||||||
|
1.1 arp_proxy
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# file: /etc/sysctl.conf
|
||||||
|
net.ipv4.conf.all.proxy_arp = 1
|
||||||
|
|
||||||
|
#执行如下命令
|
||||||
|
sysctl -w net.ipv4.conf.all.proxy_arp=1
|
||||||
|
|
||||||
|
|
||||||
|
配置文件修改:
|
||||||
|
|
||||||
# 首先关闭nat转发功能
|
# 首先关闭nat转发功能
|
||||||
iptables_nat = false
|
iptables_nat = false
|
||||||
|
|
||||||
# master网卡需要打开混杂模式
|
|
||||||
|
link_mode = "tun"
|
||||||
|
#内网主网卡名称
|
||||||
|
ipv4_master = "eth0"
|
||||||
|
#以下网段需要跟ipv4_master网卡设置成一样
|
||||||
|
ipv4_cidr = "10.1.2.0/24"
|
||||||
|
ipv4_gateway = "10.1.2.99"
|
||||||
|
ipv4_start = "10.1.2.100"
|
||||||
|
ipv4_end = "10.1.2.200"
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
1.2 macvtap
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
# 命令行执行 master网卡需要打开混杂模式
|
||||||
ip link set dev eth0 promisc on
|
ip link set dev eth0 promisc on
|
||||||
|
|
||||||
|
#=====================#
|
||||||
|
|
||||||
|
# 配置文件修改
|
||||||
|
# 首先关闭nat转发功能
|
||||||
|
iptables_nat = false
|
||||||
|
|
||||||
|
link_mode = "macvtap"
|
||||||
#内网主网卡名称
|
#内网主网卡名称
|
||||||
ipv4_master = "eth0"
|
ipv4_master = "eth0"
|
||||||
#以下网段需要跟ipv4_master网卡设置成一样
|
#以下网段需要跟ipv4_master网卡设置成一样
|
||||||
@@ -226,28 +316,36 @@ ipv4_start = "10.1.2.100"
|
|||||||
ipv4_end = "10.1.2.200"
|
ipv4_end = "10.1.2.200"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Systemd
|
## Deploy
|
||||||
|
|
||||||
|
> 部署配置文件放在 `deploy` 目录下,请根据实际情况修改配置文件
|
||||||
|
|
||||||
|
### Systemd
|
||||||
|
|
||||||
1. 添加 anylink 程序
|
1. 添加 anylink 程序
|
||||||
|
- 首先把 `anylink-deploy` 文件夹放入 `/usr/local/anylink-deploy`
|
||||||
- anylink 程序目录放入 `/usr/local/anylink-deploy`
|
|
||||||
- 添加执行权限 `chmod +x /usr/local/anylink-deploy/anylink`
|
- 添加执行权限 `chmod +x /usr/local/anylink-deploy/anylink`
|
||||||
|
2. 把 `anylink.service` 脚本放入:
|
||||||
2. systemd/anylink.service 脚本放入:
|
|
||||||
|
|
||||||
- centos: `/usr/lib/systemd/system/`
|
- centos: `/usr/lib/systemd/system/`
|
||||||
- ubuntu: `/lib/systemd/system/`
|
- ubuntu: `/lib/systemd/system/`
|
||||||
|
|
||||||
3. 操作命令:
|
3. 操作命令:
|
||||||
|
|
||||||
- 启动: `systemctl start anylink`
|
- 启动: `systemctl start anylink`
|
||||||
- 停止: `systemctl stop anylink`
|
- 停止: `systemctl stop anylink`
|
||||||
- 开机自启: `systemctl enable anylink`
|
- 开机自启: `systemctl enable anylink`
|
||||||
|
|
||||||
|
### Docker Compose
|
||||||
|
|
||||||
|
1. 进入 `deploy` 目录
|
||||||
|
2. 执行脚本 `docker-compose up`
|
||||||
|
|
||||||
|
### k8s
|
||||||
|
|
||||||
|
1. 进入 `deploy` 目录
|
||||||
|
2. 执行脚本 `kubectl apply -f deployment.yaml`
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
1. 获取镜像
|
1. 获取镜像
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 具体tag可以从docker hub获取
|
# 具体tag可以从docker hub获取
|
||||||
# https://hub.docker.com/r/bjdgyc/anylink/tags
|
# https://hub.docker.com/r/bjdgyc/anylink/tags
|
||||||
@@ -255,50 +353,67 @@ ipv4_end = "10.1.2.200"
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. 查看命令信息
|
2. 查看命令信息
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm bjdgyc/anylink -h
|
docker run -it --rm bjdgyc/anylink -h
|
||||||
```
|
```
|
||||||
|
|
||||||
3. 生成密码
|
3. 生成密码
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm bjdgyc/anylink tool -p 123456
|
docker run -it --rm bjdgyc/anylink tool -p 123456
|
||||||
#Passwd:$2a$10$lCWTCcGmQdE/4Kb1wabbLelu4vY/cUwBwN64xIzvXcihFgRzUvH2a
|
#Passwd:$2a$10$lCWTCcGmQdE/4Kb1wabbLelu4vY/cUwBwN64xIzvXcihFgRzUvH2a
|
||||||
```
|
```
|
||||||
|
|
||||||
4. 生成 jwt secret
|
4. 生成 jwt secret
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm bjdgyc/anylink tool -s
|
docker run -it --rm bjdgyc/anylink tool -s
|
||||||
#Secret:9qXoIhY01jqhWIeIluGliOS4O_rhcXGGGu422uRZ1JjZxIZmh17WwzW36woEbA
|
#Secret:9qXoIhY01jqhWIeIluGliOS4O_rhcXGGGu422uRZ1JjZxIZmh17WwzW36woEbA
|
||||||
```
|
```
|
||||||
|
|
||||||
5. 启动容器
|
5. 查看所有配置项
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
docker run -it --rm bjdgyc/anylink tool -d
|
||||||
|
```
|
||||||
|
|
||||||
|
6. 启动容器
|
||||||
|
```bash
|
||||||
|
# 默认启动
|
||||||
docker run -itd --name anylink --privileged \
|
docker run -itd --name anylink --privileged \
|
||||||
-p 443:443 -p 8800:8800 \
|
-p 443:443 -p 8800:8800 -p 443:443/udp \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
bjdgyc/anylink
|
bjdgyc/anylink
|
||||||
|
|
||||||
|
# 自定义配置目录
|
||||||
|
# 首次启动会自动创建配置文件
|
||||||
|
# 配置文件初始化完成后,容器会强制退出,请重新启动容器
|
||||||
|
docker run -itd --name anylink --privileged \
|
||||||
|
-p 443:443 -p 8800:8800 -p 443:443/udp \
|
||||||
|
-v /home/myconf:/app/conf \
|
||||||
|
--restart=always \
|
||||||
|
bjdgyc/anylink
|
||||||
|
|
||||||
|
docker restart anylink
|
||||||
```
|
```
|
||||||
|
|
||||||
6. 使用自定义参数启动容器
|
6. 使用自定义参数启动容器
|
||||||
```bash
|
```bash
|
||||||
# 参数可以参考 -h 命令
|
# 参数可以参考 ./anylink tool -d
|
||||||
|
# 可以使用命令行参数 或者 环境变量 配置
|
||||||
docker run -itd --name anylink --privileged \
|
docker run -itd --name anylink --privileged \
|
||||||
-p 443:443 -p 8800:8800 \
|
-e LINK_LOG_LEVEL=info \
|
||||||
|
-p 443:443 -p 8800:8800 -p 443:443/udp \
|
||||||
|
-v /home/myconf:/app/conf \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
bjdgyc/anylink \
|
bjdgyc/anylink \
|
||||||
-c=/etc/server.toml --ip_lease=1209600 # IP地址租约时长
|
--ip_lease=1209600 # IP地址租约时长
|
||||||
```
|
```
|
||||||
|
|
||||||
7. 构建镜像 (非必需)
|
7. 构建镜像 (非必需)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#获取仓库源码
|
#获取仓库源码
|
||||||
git clone https://github.com/bjdgyc/anylink.git
|
git clone https://github.com/bjdgyc/anylink.git
|
||||||
# 构建镜像
|
# 构建镜像
|
||||||
|
sh build_docker.sh
|
||||||
|
或
|
||||||
docker build -t anylink -f docker/Dockerfile .
|
docker build -t anylink -f docker/Dockerfile .
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -306,20 +421,31 @@ ipv4_end = "10.1.2.200"
|
|||||||
|
|
||||||
请前往 [问题地址](doc/question.md) 查看具体信息
|
请前往 [问题地址](doc/question.md) 查看具体信息
|
||||||
|
|
||||||
|
<!--
|
||||||
## Discussion
|
## Discussion
|
||||||
|
|
||||||
添加QQ群(1): 567510628
|
|
||||||
|
|
||||||
添加QQ群(2): 739072205
|
|
||||||
|
|
||||||
群共享文件有相关软件下载
|
群共享文件有相关软件下载
|
||||||
|
|
||||||
<!--
|
|
||||||
添加微信群: 群共享文件有相关软件下载
|
添加微信群: 群共享文件有相关软件下载
|
||||||
|
|
||||||

|

|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## Support Document
|
||||||
|
|
||||||
|
- [三方文档-男孩的天职](https://note.youdao.com/s/X4AxyWfL)
|
||||||
|
- [三方文档-issues](https://github.com/bjdgyc/anylink/issues)
|
||||||
|
- [三方文档-思有云](https://www.ioiox.com/archives/128.html)
|
||||||
|
- [三方文档-啵品](https://yangpin.link/archives/1633.html)
|
||||||
|
|
||||||
|
## Support Client
|
||||||
|
|
||||||
|
- [AnyConnect Secure Client](https://www.cisco.com/) (可通过群文件下载: Windows/macOS/Linux/Android/iOS)
|
||||||
|
- [OpenConnect](https://gitlab.com/openconnect/openconnect) (Windows/macOS/Linux)
|
||||||
|
- [三方 AnyLink Secure Client](https://github.com/tlslink/anylink-client) (Windows/macOS/Linux)
|
||||||
|
- [三方客户端下载地址](https://cisco.yangpin.link) (Windows/macOS/Linux/Android/iOS)
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
欢迎提交 PR、Issues,感谢为 AnyLink 做出贡献。
|
欢迎提交 PR、Issues,感谢为 AnyLink 做出贡献。
|
||||||
|
63
build.sh
63
build.sh
@@ -1,61 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -x
|
|
||||||
function RETVAL() {
|
|
||||||
rt=$1
|
|
||||||
if [ $rt != 0 ]; then
|
|
||||||
echo $rt
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#当前目录
|
#当前目录
|
||||||
cpath=$(pwd)
|
cpath=$(pwd)
|
||||||
|
|
||||||
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
ver=$(cat version)
|
||||||
echo "当前版本 $ver"
|
echo $ver
|
||||||
|
|
||||||
echo "编译前端项目"
|
#前端编译 仅需要执行一次
|
||||||
cd $cpath/web
|
#bash ./build_web.sh
|
||||||
#国内可替换源加快速度
|
|
||||||
#npx browserslist@latest --update-db
|
|
||||||
#npm install --registry=https://registry.npm.taobao.org
|
|
||||||
#npm install
|
|
||||||
#npm run build
|
|
||||||
|
|
||||||
yarn install --registry=https://registry.npmmirror.com
|
bash build_docker.sh
|
||||||
yarn run build
|
|
||||||
|
deploy="anylink-deploy-$ver"
|
||||||
|
docker container rm $deploy
|
||||||
|
docker container create --name $deploy bjdgyc/anylink:$ver
|
||||||
|
rm -rf anylink-deploy anylink-deploy.tar.gz
|
||||||
|
docker cp -a $deploy:/app ./anylink-deploy
|
||||||
|
tar zcf ${deploy}.tar.gz anylink-deploy
|
||||||
|
|
||||||
|
|
||||||
RETVAL $?
|
./anylink-deploy/anylink -v
|
||||||
|
|
||||||
echo "编译二进制文件"
|
|
||||||
cd $cpath/server
|
|
||||||
rm -rf ui
|
|
||||||
cp -rf $cpath/web/ui .
|
|
||||||
#国内可替换源加快速度
|
|
||||||
export GOPROXY=https://goproxy.io
|
|
||||||
go mod tidy
|
|
||||||
go build -v -o anylink -ldflags "-s -w -X main.CommitId=$(git rev-parse HEAD)"
|
|
||||||
RETVAL $?
|
|
||||||
|
|
||||||
cd $cpath
|
echo "anylink 编译完成,目录: anylink-deploy"
|
||||||
|
ls -lh anylink-deploy
|
||||||
|
|
||||||
echo "整理部署文件"
|
|
||||||
deploy="anylink-deploy"
|
|
||||||
rm -rf $deploy ${deploy}.tar.gz
|
|
||||||
mkdir $deploy
|
|
||||||
|
|
||||||
cp -r server/anylink $deploy
|
|
||||||
#cp -r server/bridge-init.sh $deploy
|
|
||||||
cp -r server/conf $deploy
|
|
||||||
|
|
||||||
cp -r systemd $deploy
|
|
||||||
cp -r LICENSE $deploy
|
|
||||||
cp -r home $deploy
|
|
||||||
|
|
||||||
tar zcvf ${deploy}.tar.gz $deploy
|
|
||||||
|
|
||||||
#注意使用root权限运行
|
|
||||||
#cd anylink-deploy
|
|
||||||
#sudo ./anylink --conf="conf/server.toml"
|
|
||||||
|
@@ -1,18 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
ver=$(cat version)
|
||||||
echo $ver
|
echo $ver
|
||||||
|
|
||||||
#docker login -u bjdgyc
|
# docker login -u bjdgyc
|
||||||
|
|
||||||
#docker build -t bjdgyc/anylink .
|
# 生成时间 2024-01-30T21:41:27+08:00
|
||||||
|
# date -Iseconds
|
||||||
|
|
||||||
docker build -t bjdgyc/anylink --build-arg GitCommitId=$(git rev-parse HEAD) -f docker/Dockerfile .
|
#bash ./build_web.sh
|
||||||
|
|
||||||
|
# docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 本地不生成镜像
|
||||||
|
docker build -t bjdgyc/anylink:latest --no-cache --progress=plain \
|
||||||
|
--build-arg CN="yes" --build-arg appVer=$ver --build-arg commitId=$(git rev-parse HEAD) \
|
||||||
|
-f docker/Dockerfile .
|
||||||
|
|
||||||
|
echo "docker tag latest $ver"
|
||||||
docker tag bjdgyc/anylink:latest bjdgyc/anylink:$ver
|
docker tag bjdgyc/anylink:latest bjdgyc/anylink:$ver
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
docker push bjdgyc/anylink:$ver
|
docker tag bjdgyc/anylink:latest registry.cn-qingdao.aliyuncs.com/bjdgyc/anylink:latest
|
||||||
docker push bjdgyc/anylink:latest
|
|
||||||
|
|
||||||
|
docker push registry.cn-qingdao.aliyuncs.com/bjdgyc/anylink:latest
|
||||||
|
72
build_test.sh
Normal file
72
build_test.sh
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#github action release.sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
function RETVAL() {
|
||||||
|
rt=$1
|
||||||
|
if [ $rt != 0 ]; then
|
||||||
|
echo $rt
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#当前目录
|
||||||
|
cpath=$(pwd)
|
||||||
|
|
||||||
|
ver=$(cat version)
|
||||||
|
echo $ver
|
||||||
|
|
||||||
|
#前端编译 仅需要执行一次
|
||||||
|
#bash ./build_web.sh
|
||||||
|
|
||||||
|
echo "copy二进制文件"
|
||||||
|
|
||||||
|
# -tags osusergo,netgo,sqlite_omit_load_extension
|
||||||
|
flags="-trimpath"
|
||||||
|
ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.buildDate=$(date --iso-8601=seconds)"
|
||||||
|
#github action
|
||||||
|
gopath=/go
|
||||||
|
|
||||||
|
dockercmd=$(
|
||||||
|
cat <<EOF
|
||||||
|
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||||
|
apk add gcc g++ musl musl-dev tzdata
|
||||||
|
export GOPROXY=https://goproxy.cn
|
||||||
|
go mod tidy
|
||||||
|
echo "build:"
|
||||||
|
rm anylink
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
go build -v -o anylink $flags -ldflags "$ldflags"
|
||||||
|
./anylink -v
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
#使用 musl-dev 编译
|
||||||
|
docker run -q --rm -v $PWD/server:/app -v $gopath:/go -w /app --platform=linux/amd64 \
|
||||||
|
golang:1.20-alpine3.19 sh -c "$dockercmd"
|
||||||
|
|
||||||
|
#arm64编译
|
||||||
|
#docker run -q --rm -v $PWD/server:/app -v $gopath:/go -w /app --platform=linux/arm64 \
|
||||||
|
# golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags"
|
||||||
|
#exit 0
|
||||||
|
|
||||||
|
#cd $cpath
|
||||||
|
|
||||||
|
echo "整理部署文件"
|
||||||
|
rm -rf anylink-deploy anylink-deploy.tar.gz
|
||||||
|
mkdir anylink-deploy
|
||||||
|
mkdir anylink-deploy/log
|
||||||
|
|
||||||
|
cp -r server/anylink anylink-deploy
|
||||||
|
cp -r server/conf anylink-deploy
|
||||||
|
|
||||||
|
cp -r index_template anylink-deploy
|
||||||
|
cp -r deploy anylink-deploy
|
||||||
|
cp -r LICENSE anylink-deploy
|
||||||
|
|
||||||
|
tar zcvf anylink-deploy.tar.gz anylink-deploy
|
||||||
|
|
||||||
|
#注意使用root权限运行
|
||||||
|
#cd anylink-deploy
|
||||||
|
#sudo ./anylink --conf="conf/server.toml"
|
9
build_web.sh
Normal file
9
build_web.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm -rf web/ui server/ui
|
||||||
|
|
||||||
|
docker run -it --rm -v $PWD/web:/app -w /app node:16-alpine \
|
||||||
|
sh -c "yarn install --registry=https://registry.npmmirror.com && yarn run build"
|
||||||
|
|
||||||
|
|
||||||
|
cp -r web/ui server/ui
|
@@ -17,8 +17,8 @@ ExecStart=/usr/local/anylink-deploy/anylink --conf=/usr/local/anylink-deploy/con
|
|||||||
# ExecStart=/bin/bash -c 'exec /usr/local/anylink-deploy/anylink --conf=/usr/local/anylink-deploy/conf/server.toml >> /usr/local/anylink-deploy/log/anylink.log 2>&1'
|
# ExecStart=/bin/bash -c 'exec /usr/local/anylink-deploy/anylink --conf=/usr/local/anylink-deploy/conf/server.toml >> /usr/local/anylink-deploy/log/anylink.log 2>&1'
|
||||||
|
|
||||||
# systemd new than v236
|
# systemd new than v236
|
||||||
# StandardOutput=file:/usr/local/anylink-deploy/log/anylink.log
|
# StandardOutput=file:/usr/local/anylink-deploy/log/anylink-systemd.log
|
||||||
# StandardError=file:/usr/local/anylink-deploy/log/anylink.log
|
# StandardError=file:/usr/local/anylink-deploy/log/anylink-systemd.log
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
101
deploy/deployment.yaml
Normal file
101
deploy/deployment.yaml
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: anylink
|
||||||
|
namespace: default
|
||||||
|
labels:
|
||||||
|
link-app: anylink
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
link-app: anylink
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
link-app: anylink
|
||||||
|
spec:
|
||||||
|
#hostNetwork: true
|
||||||
|
dnsPolicy: ClusterFirst
|
||||||
|
containers:
|
||||||
|
- name: anylink
|
||||||
|
env:
|
||||||
|
- name: NODE_NAME
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
apiVersion: v1
|
||||||
|
fieldPath: spec.nodeName
|
||||||
|
- name: GOMAXPROCS
|
||||||
|
valueFrom:
|
||||||
|
resourceFieldRef:
|
||||||
|
resource: limits.cpu
|
||||||
|
- name: POD_CPU_LIMIT
|
||||||
|
valueFrom:
|
||||||
|
resourceFieldRef:
|
||||||
|
resource: limits.cpu
|
||||||
|
- name: POD_MEMORY_LIMIT
|
||||||
|
valueFrom:
|
||||||
|
resourceFieldRef:
|
||||||
|
resource: limits.memory
|
||||||
|
- name: TZ
|
||||||
|
value: "Asia/Shanghai"
|
||||||
|
image: bjdgyc/anylink:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
args:
|
||||||
|
- --conf=/app/conf/server.toml
|
||||||
|
ports:
|
||||||
|
- name: https
|
||||||
|
containerPort: 443
|
||||||
|
protocol: TCP
|
||||||
|
- name: https-admin
|
||||||
|
containerPort: 8800
|
||||||
|
protocol: TCP
|
||||||
|
- name: dtls
|
||||||
|
containerPort: 443
|
||||||
|
protocol: UDP
|
||||||
|
# 设置资源
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "2"
|
||||||
|
memory: 4Gi
|
||||||
|
ephemeral-storage: "2Gi"
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
# 禁用自动注入 service 信息到环境变量
|
||||||
|
enableServiceLinks: false
|
||||||
|
restartPolicy: Always
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/os: linux
|
||||||
|
securityContext: { }
|
||||||
|
tolerations:
|
||||||
|
- operator: Exists
|
||||||
|
#设置优先级
|
||||||
|
priorityClassName: system-cluster-critical
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: anylink
|
||||||
|
namespace: default
|
||||||
|
labels:
|
||||||
|
link-app: anylink
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: https
|
||||||
|
port: 443
|
||||||
|
targetPort: 443
|
||||||
|
protocol: TCP
|
||||||
|
- name: https-admin
|
||||||
|
port: 8800
|
||||||
|
targetPort: 8800
|
||||||
|
protocol: TCP
|
||||||
|
- name: dtls
|
||||||
|
port: 443
|
||||||
|
targetPort: 443
|
||||||
|
protocol: UDP
|
||||||
|
selector:
|
||||||
|
link-app: anylink
|
||||||
|
sessionAffinity: ClientIP
|
||||||
|
type: ClusterIP
|
19
deploy/docker-compose.yaml
Normal file
19
deploy/docker-compose.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
anylink:
|
||||||
|
image: bjdgyc/anylink:latest
|
||||||
|
container_name: anylink
|
||||||
|
restart: always
|
||||||
|
privileged: true
|
||||||
|
#cpus: 2
|
||||||
|
#mem_limit: 4g
|
||||||
|
ports:
|
||||||
|
- 443:443
|
||||||
|
- 8800:8800
|
||||||
|
- 443:443/udp
|
||||||
|
environment:
|
||||||
|
LINK_LOG_LEVEL: info
|
||||||
|
command:
|
||||||
|
- --conf=/app/conf/server.toml
|
||||||
|
#volumes:
|
||||||
|
# - /home/myconf:/app/conf
|
||||||
|
dns_search: .
|
@@ -12,7 +12,7 @@
|
|||||||
>
|
>
|
||||||
> 需要展示主页的同学,可以在QQ群 直接联系我添加。
|
> 需要展示主页的同学,可以在QQ群 直接联系我添加。
|
||||||
|
|
||||||
| 昵称 | 主页 / 留言 |
|
| 昵称 | 主页 / 联系方式 |
|
||||||
|-----------|------------------------------|
|
|-----------|------------------------------|
|
||||||
| 代码 oo8 | |
|
| 代码 oo8 | |
|
||||||
| 甘磊 | https://github.com/ganlei333 |
|
| 甘磊 | https://github.com/ganlei333 |
|
||||||
@@ -40,9 +40,10 @@
|
|||||||
| 悲鸣 | |
|
| 悲鸣 | |
|
||||||
| 谢谢 | |
|
| 谢谢 | |
|
||||||
| 云思科技 | |
|
| 云思科技 | |
|
||||||
| 哆啦A伟(张佳伟) | 嘿嘿 |
|
| 哆啦A伟(张佳伟) | |
|
||||||
| 人类的悲欢并不相通 | 开源不易,感谢分享 |
|
| 人类的悲欢并不相通 | |
|
||||||
| 做人要低调 | |
|
| 做人要低调 | |
|
||||||
|
| 洛洛 | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
> 请使用手机安装 freeotp ,然后扫描otp二维码,生成的数字即是动态码
|
> 请使用手机安装 freeotp ,然后扫描otp二维码,生成的数字即是动态码
|
||||||
|
|
||||||
|
### 用户策略问题
|
||||||
|
|
||||||
|
> 只要有用户策略,组策略就不生效,相当于覆盖了组策略的配置
|
||||||
|
|
||||||
### 远程桌面连接
|
### 远程桌面连接
|
||||||
|
|
||||||
> 本软件已经支持远程桌面里面连接anyconnect。
|
> 本软件已经支持远程桌面里面连接anyconnect。
|
||||||
@@ -46,6 +50,12 @@ mobile_dpd = 15
|
|||||||
>
|
>
|
||||||
> 如经常出现 timeout 的错误信息,应根据当前防火墙的设置,适当减小dpd数值
|
> 如经常出现 timeout 的错误信息,应根据当前防火墙的设置,适当减小dpd数值
|
||||||
|
|
||||||
|
### 关于审计日志 audit_interval 参数
|
||||||
|
|
||||||
|
> 默认值 `audit_interval = 600` 表示相同日志600秒内只记录一次,不同日志首次出现立即记录
|
||||||
|
>
|
||||||
|
> 去重key的格式: 16字节源IP地址 + 16字节目的IP地址 + 2字节目的端口 + 1字节协议类型 + 16字节域名MD5
|
||||||
|
|
||||||
### 反向代理问题
|
### 反向代理问题
|
||||||
|
|
||||||
> anylink 仅支持四层反向代理,不支持七层反向代理
|
> anylink 仅支持四层反向代理,不支持七层反向代理
|
||||||
|
@@ -1,57 +1,58 @@
|
|||||||
#node:16-bullseye
|
#node:16-bullseye
|
||||||
#golang:1.20-bullseye
|
#golang:1.20-bullseye
|
||||||
#debian:bullseye-slim
|
#debian:bullseye-slim
|
||||||
#sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
#bullseye
|
||||||
|
# sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||||
|
#bookworm
|
||||||
|
# sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
|
||||||
|
|
||||||
|
# sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||||
|
|
||||||
|
|
||||||
# web
|
# 配合 github action 使用
|
||||||
FROM node:16-alpine3.18 as builder_node
|
# 需要先编译出ui文件后 再执行docker编译
|
||||||
WORKDIR /web
|
|
||||||
COPY ./web /web
|
|
||||||
RUN yarn install \
|
|
||||||
&& yarn run build \
|
|
||||||
&& ls /web/ui
|
|
||||||
|
|
||||||
|
|
||||||
# server
|
# server
|
||||||
FROM golang:1.20-alpine3.18 as builder_golang
|
FROM golang:1.20-alpine3.19 as builder_golang
|
||||||
#TODO 本地打包时使用镜像
|
|
||||||
ENV GOPROXY=https://goproxy.cn
|
|
||||||
ENV GOOS=linux
|
|
||||||
ARG GitCommitId="gitCommitId"
|
|
||||||
|
|
||||||
WORKDIR /anylink
|
ARG CN="no"
|
||||||
COPY server /anylink
|
ARG appVer="appVer"
|
||||||
COPY --from=builder_node /web/ui /anylink/ui
|
ARG commitId="commitId"
|
||||||
|
|
||||||
#TODO 本地打包时使用镜像
|
ENV TZ=Asia/Shanghai
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
|
||||||
RUN apk add gcc musl-dev
|
WORKDIR /server
|
||||||
RUN cd /anylink;go mod tidy;go build -o anylink -ldflags "-s -w -X main.CommitId=${GitCommitId}" \
|
COPY docker/init_build.sh /tmp/
|
||||||
&& /anylink/anylink tool -v
|
COPY server/ /server/
|
||||||
|
COPY web/ui /server/ui
|
||||||
|
|
||||||
|
#RUN apk add gcc musl-dev bash
|
||||||
|
RUN sh /tmp/init_build.sh
|
||||||
|
|
||||||
|
|
||||||
# anylink
|
# anylink
|
||||||
FROM alpine:3.18
|
FROM alpine:3.19
|
||||||
LABEL maintainer="github.com/bjdgyc"
|
LABEL maintainer="github.com/bjdgyc"
|
||||||
|
|
||||||
|
ARG CN="no"
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
ENV ANYLINK_IN_CONTAINER=true
|
ENV ANYLINK_IN_CONTAINER=true
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder_golang /anylink/anylink /app/
|
COPY docker/init_release.sh /tmp/
|
||||||
COPY docker/docker_entrypoint.sh /app/
|
|
||||||
COPY ./server/bridge-init.sh /app/
|
COPY --from=builder_golang /server/anylink /app/
|
||||||
|
COPY docker/docker_entrypoint.sh server/bridge-init.sh ./README.md ./LICENSE version_info /app/
|
||||||
|
COPY ./deploy /app/deploy
|
||||||
|
COPY ./index_template /app/index_template
|
||||||
COPY ./server/conf /app/conf
|
COPY ./server/conf /app/conf
|
||||||
COPY ./LICENSE /app/LICENSE
|
|
||||||
COPY ./home /app/home
|
|
||||||
|
|
||||||
#TODO 本地打包时使用镜像
|
#TODO 本地打包时使用镜像
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
RUN sh /tmp/init_release.sh
|
||||||
RUN apk add --no-cache bash iptables \
|
|
||||||
&& chmod +x /app/docker_entrypoint.sh \
|
|
||||||
&& ls /app
|
|
||||||
|
|
||||||
EXPOSE 443 8800
|
|
||||||
|
EXPOSE 443 8800 443/udp
|
||||||
|
|
||||||
#CMD ["/app/anylink"]
|
#CMD ["/app/anylink"]
|
||||||
ENTRYPOINT ["/app/docker_entrypoint.sh"]
|
ENTRYPOINT ["/app/docker_entrypoint.sh"]
|
||||||
|
@@ -18,6 +18,14 @@ case $var1 in
|
|||||||
#iptables -t nat -A POSTROUTING -s "${IPV4_CIDR}" -o eth0+ -j MASQUERADE
|
#iptables -t nat -A POSTROUTING -s "${IPV4_CIDR}" -o eth0+ -j MASQUERADE
|
||||||
#iptables -nL -t nat
|
#iptables -nL -t nat
|
||||||
|
|
||||||
|
# 启动服务 先判断配置文件是否存在
|
||||||
|
if [ ! -f /app/conf/profile.xml ]; then
|
||||||
|
/bin/cp -r /home/conf-bak/* /app/conf/
|
||||||
|
echo "After the configuration file is initialized, the container will be forcibly exited. Restart the container."
|
||||||
|
echo "配置文件初始化完成后,容器会强制退出,请重新启动容器。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
exec /app/anylink "$@"
|
exec /app/anylink "$@"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
34
docker/init_build.sh
Normal file
34
docker/init_build.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
#TODO 本地打包时使用镜像
|
||||||
|
if [[ $CN == "yes" ]]; then
|
||||||
|
#sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||||
|
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||||
|
export GOPROXY=https://goproxy.cn
|
||||||
|
fi
|
||||||
|
|
||||||
|
apk add build-base tzdata gcc g++ musl musl-dev upx
|
||||||
|
|
||||||
|
uname -a
|
||||||
|
env
|
||||||
|
date
|
||||||
|
|
||||||
|
cd /server
|
||||||
|
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
echo "start build"
|
||||||
|
|
||||||
|
ldflags="-s -w -X main.appVer=$appVer -X main.commitId=$commitId -X main.buildDate=$(date -Iseconds) -extldflags \"-static\" "
|
||||||
|
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
go build -v -o anylink -trimpath -ldflags "$ldflags"
|
||||||
|
|
||||||
|
ls -lh /server/
|
||||||
|
|
||||||
|
# 压缩文件
|
||||||
|
upx -9 -k anylink
|
||||||
|
|
||||||
|
/server/anylink -v
|
27
docker/init_release.sh
Normal file
27
docker/init_release.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
#TODO 本地打包时使用镜像
|
||||||
|
if [[ $CN == "yes" ]]; then
|
||||||
|
#sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||||
|
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
||||||
|
export GOPROXY=https://goproxy.cn
|
||||||
|
fi
|
||||||
|
|
||||||
|
# alpine:3.19 兼容老版 iptables
|
||||||
|
apk add --no-cache iptables iptables-legacy
|
||||||
|
rm /sbin/iptables
|
||||||
|
ln -s /sbin/iptables-legacy /sbin/iptables
|
||||||
|
|
||||||
|
apk add --no-cache ca-certificates bash iproute2 tzdata
|
||||||
|
chmod +x /app/docker_entrypoint.sh
|
||||||
|
mkdir /app/log
|
||||||
|
|
||||||
|
#备份配置文件
|
||||||
|
cp -r /app/conf /home/conf-bak
|
||||||
|
|
||||||
|
tree /app
|
||||||
|
|
||||||
|
uname -a
|
||||||
|
date -Iseconds
|
165
index_template/自定义首页2.html
Normal file
165
index_template/自定义首页2.html
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset=UTF-8">
|
||||||
|
<title id="pageTitle">客户端下载</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
background-image: linear-gradient(0deg, transparent 24%, rgba(207, 207, 207, 0.2) 25%, rgba(207, 207, 207, 0.2) 26%, transparent 27%, transparent 74%, rgba(207, 207, 207, 0.2) 75%, rgba(207, 207, 207, 0.2) 76%, transparent 77%, transparent),
|
||||||
|
linear-gradient(90deg, transparent 24%, rgba(207, 207, 207, 0.2) 25%, rgba(207, 207, 207, 0.2) 26%, transparent 27%, transparent 74%, rgba(207, 207, 207, 0.2) 75%, rgba(207, 207, 207, 0.2) 76%, transparent 77%, transparent);
|
||||||
|
background-size: 50px 50px;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
#box {
|
||||||
|
background-color: #ffffff;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
position: relative;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
max-width: 550px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
color: #333;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 28px;
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: #666;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
background-color: #ddd;
|
||||||
|
text-decoration: none;
|
||||||
|
line-height: 44px;
|
||||||
|
padding: 9px 42px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
-webkit-transition: background-color 0.25s ease-out 0s;
|
||||||
|
-moz-transition: background-color 0.25s ease-out 0s;
|
||||||
|
transition: background-color 0.25s ease-out 0s;
|
||||||
|
-moz-border-radius: 4px;
|
||||||
|
-webkit-border-radius: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
background-color: #CCC;
|
||||||
|
color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:active {
|
||||||
|
background-color: #666;
|
||||||
|
color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blue {
|
||||||
|
background-color: #007BFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deep-blue {
|
||||||
|
background-color: #0056B3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.green {
|
||||||
|
background-color: #28A745;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grey {
|
||||||
|
background-color: #6C757D;
|
||||||
|
}
|
||||||
|
|
||||||
|
.black {
|
||||||
|
background-color: #343A40;
|
||||||
|
}
|
||||||
|
|
||||||
|
.light-blue {
|
||||||
|
background-color: #17A2B8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-grey {
|
||||||
|
background-color: #495057;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
padding: 7px 35px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<div id="box">
|
||||||
|
<h2 id="title">请选择对应平台下载</h2>
|
||||||
|
<p id="windowsTab">Windows 系统</p>
|
||||||
|
<a id="linkWindowsX86_64" class="button blue" href="#">Win X86_64</a>
|
||||||
|
<a id="linkWindowsARM64" class="button deep-blue" href="#">Win ARM64</a>
|
||||||
|
|
||||||
|
<p id="mobileTab">移动端</p>
|
||||||
|
<a id="linkAndroid" class="button green" href="#">Android</a>
|
||||||
|
<a id="linkIphone" class="button grey" href="#" target="_blank">iPhone</a>
|
||||||
|
|
||||||
|
<p id="macOSTab">MacOS 系统</p>
|
||||||
|
<a id="linkMacos" class="button black" href="#">Mac Intel</a>
|
||||||
|
<a id="linkMacosARM64" class="button blue" href="#">Mac ARM64</a>
|
||||||
|
|
||||||
|
<p id="totpTab">TOTP 移动客户端</p>
|
||||||
|
<a id="linkTotpAndroid" class="button light-blue" href="#">Android</a>
|
||||||
|
<a id="linkTotpIphone" class="button dark-grey" href="#" target="_blank">iPhone</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
const data = {
|
||||||
|
links: {
|
||||||
|
windowsX86_64: '/files/anyconnect-win-4.10.05111.msi',
|
||||||
|
windowsARM64: '/files/anyconnect-win-4.10.05111.msi',
|
||||||
|
android: '/files/CiscoSecureClientAnyConnect_v5.0.00247.apk',
|
||||||
|
iphone: 'https://apps.apple.com/cn/app/cisco-anyconnect/id1135064690',
|
||||||
|
macosIntel: '/files/anyconnect-macos-4.10.05111.dmg',
|
||||||
|
macosARM64: '/files/anyconnect-macos-4.10.05111.dmg',
|
||||||
|
totpAndroid: '/files/Authenticator_v5.10_apkpure.com.apk',
|
||||||
|
totpIphone: 'https://apps.apple.com/cn/app/google-authenticator/id388497605',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
|
document.getElementById('linkWindowsX86_64').href = data.links.windowsX86_64;
|
||||||
|
document.getElementById('linkWindowsARM64').href = data.links.windowsARM64;
|
||||||
|
document.getElementById('linkAndroid').href = data.links.android;
|
||||||
|
document.getElementById('linkIphone').href = data.links.iphone;
|
||||||
|
document.getElementById('linkMacos').href = data.links.macosIntel;
|
||||||
|
document.getElementById('linkMacosARM64').href = data.links.macosARM64;
|
||||||
|
document.getElementById('linkTotpAndroid').href = data.links.totpAndroid;
|
||||||
|
document.getElementById('linkTotpIphone').href = data.links.totpIphone;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
50
release.sh
Normal file
50
release.sh
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#github action release.sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
function RETVAL() {
|
||||||
|
rt=$1
|
||||||
|
if [ $rt != 0 ]; then
|
||||||
|
echo $rt
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#当前目录
|
||||||
|
cpath=$(pwd)
|
||||||
|
|
||||||
|
ver=$(cat version)
|
||||||
|
echo "当前版本 $ver"
|
||||||
|
|
||||||
|
rm -rf artifact-dist
|
||||||
|
mkdir artifact-dist
|
||||||
|
|
||||||
|
function archive() {
|
||||||
|
arch=$1
|
||||||
|
#echo "整理部署文件 $arch"
|
||||||
|
arch_name=${arch//\//-}
|
||||||
|
echo $arch_name
|
||||||
|
|
||||||
|
deploy="anylink-$ver-$arch_name"
|
||||||
|
docker container rm $deploy
|
||||||
|
docker container create --platform $arch --name $deploy bjdgyc/anylink:$ver
|
||||||
|
rm -rf anylink-deploy
|
||||||
|
docker cp -a $deploy:/app ./anylink-deploy
|
||||||
|
|
||||||
|
ls -lh anylink-deploy
|
||||||
|
|
||||||
|
tar zcf ${deploy}.tar.gz anylink-deploy
|
||||||
|
mv ${deploy}.tar.gz artifact-dist/
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "copy二进制文件"
|
||||||
|
|
||||||
|
archive "linux/amd64"
|
||||||
|
archive "linux/arm64"
|
||||||
|
|
||||||
|
ls -lh artifact-dist
|
||||||
|
|
||||||
|
#注意使用root权限运行
|
||||||
|
#cd anylink-deploy
|
||||||
|
#sudo ./anylink --conf="conf/server.toml"
|
2
server/.gitignore
vendored
2
server/.gitignore
vendored
@@ -18,4 +18,4 @@ ui/
|
|||||||
.idea/
|
.idea/
|
||||||
anylink
|
anylink
|
||||||
data.db
|
data.db
|
||||||
conf/*.db
|
conf/*.db
|
||||||
|
@@ -36,7 +36,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
totp := gotp.NewDefaultTOTP(base.Cfg.AdminOtp)
|
totp := gotp.NewDefaultTOTP(base.Cfg.AdminOtp)
|
||||||
unix := time.Now().Unix()
|
unix := time.Now().Unix()
|
||||||
verify := totp.Verify(otp, int(unix))
|
verify := totp.Verify(otp, unix)
|
||||||
|
|
||||||
if !verify {
|
if !verify {
|
||||||
RespError(w, RespUserOrPassErr)
|
RespError(w, RespUserOrPassErr)
|
||||||
@@ -84,6 +84,7 @@ func authMiddleware(next http.Handler) http.Handler {
|
|||||||
w.Header().Set("Access-Control-Allow-Methods", "GET,POST,OPTIONS")
|
w.Header().Set("Access-Control-Allow-Methods", "GET,POST,OPTIONS")
|
||||||
w.Header().Set("Access-Control-Allow-Headers", "*")
|
w.Header().Set("Access-Control-Allow-Headers", "*")
|
||||||
if r.Method == http.MethodOptions {
|
if r.Method == http.MethodOptions {
|
||||||
|
// w.WriteHeader(http.StatusOK)
|
||||||
// 正式环境不支持 OPTIONS
|
// 正式环境不支持 OPTIONS
|
||||||
w.WriteHeader(http.StatusForbidden)
|
w.WriteHeader(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
|
@@ -66,12 +66,13 @@ func SetSystem(w http.ResponseWriter, r *http.Request) {
|
|||||||
hi, _ := host.Info()
|
hi, _ := host.Info()
|
||||||
l, _ := load.Avg()
|
l, _ := load.Avg()
|
||||||
data["sys"] = map[string]interface{}{
|
data["sys"] = map[string]interface{}{
|
||||||
"goOs": runtime.GOOS,
|
"goOs": runtime.GOOS,
|
||||||
"goArch": runtime.GOARCH,
|
"goArch": runtime.GOARCH,
|
||||||
"goVersion": runtime.Version(),
|
"goVersion": runtime.Version(),
|
||||||
"goroutine": runtime.NumGoroutine(),
|
"goroutine": runtime.NumGoroutine(),
|
||||||
"appVersion": "v" + base.APP_VER,
|
"appVersion": "v" + base.APP_VER,
|
||||||
"appCommitId": base.CommitId,
|
"appCommitId": base.CommitId,
|
||||||
|
"appBuildDate": base.BuildDate,
|
||||||
|
|
||||||
"hostname": hi.Hostname,
|
"hostname": hi.Hostname,
|
||||||
"platform": fmt.Sprintf("%v %v %v", hi.Platform, hi.PlatformFamily, hi.PlatformVersion),
|
"platform": fmt.Sprintf("%v %v %v", hi.Platform, hi.PlatformFamily, hi.PlatformVersion),
|
||||||
|
@@ -17,11 +17,13 @@ import (
|
|||||||
"github.com/bjdgyc/anylink/dbdata"
|
"github.com/bjdgyc/anylink/dbdata"
|
||||||
"github.com/bjdgyc/anylink/sessdata"
|
"github.com/bjdgyc/anylink/sessdata"
|
||||||
"github.com/skip2/go-qrcode"
|
"github.com/skip2/go-qrcode"
|
||||||
|
mail "github.com/xhit/go-simple-mail/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UserList(w http.ResponseWriter, r *http.Request) {
|
func UserList(w http.ResponseWriter, r *http.Request) {
|
||||||
_ = r.ParseForm()
|
_ = r.ParseForm()
|
||||||
prefix := r.FormValue("prefix")
|
prefix := r.FormValue("prefix")
|
||||||
|
prefix = strings.TrimSpace(prefix)
|
||||||
pageS := r.FormValue("page")
|
pageS := r.FormValue("page")
|
||||||
page, _ := strconv.Atoi(pageS)
|
page, _ := strconv.Atoi(pageS)
|
||||||
if page < 1 {
|
if page < 1 {
|
||||||
@@ -37,8 +39,11 @@ func UserList(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// 查询前缀匹配
|
// 查询前缀匹配
|
||||||
if len(prefix) > 0 {
|
if len(prefix) > 0 {
|
||||||
count = dbdata.CountPrefix("username", prefix, &dbdata.User{})
|
fuzzy := "%" + prefix + "%"
|
||||||
err = dbdata.Prefix("username", prefix, &datas, pageSize, 1)
|
where := "username LIKE ? OR nickname LIKE ? OR email LIKE ?"
|
||||||
|
|
||||||
|
count = dbdata.FindWhereCount(&dbdata.User{}, where, fuzzy, fuzzy, fuzzy)
|
||||||
|
err = dbdata.FindWhere(&datas, pageSize, page, where, fuzzy, fuzzy, fuzzy)
|
||||||
} else {
|
} else {
|
||||||
count = dbdata.CountAll(&dbdata.User{})
|
count = dbdata.CountAll(&dbdata.User{})
|
||||||
err = dbdata.Find(&datas, pageSize, page)
|
err = dbdata.Find(&datas, pageSize, page)
|
||||||
@@ -107,7 +112,7 @@ func UserSet(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//修改用户资料后执行过期用户检测
|
// 修改用户资料后执行过期用户检测
|
||||||
sessdata.CloseUserLimittimeSession()
|
sessdata.CloseUserLimittimeSession()
|
||||||
RespSucess(w, nil)
|
RespSucess(w, nil)
|
||||||
}
|
}
|
||||||
@@ -268,5 +273,13 @@ func userAccountMail(user *dbdata.User) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// fmt.Println(w.String())
|
// fmt.Println(w.String())
|
||||||
return SendMail(base.Cfg.Issuer+"平台通知", user.Email, w.String())
|
imgData, _ := userOtpQr(user.Id, false)
|
||||||
|
attach := &mail.File{
|
||||||
|
MimeType: "image/png",
|
||||||
|
Name: "userOtpQr.png",
|
||||||
|
Data: []byte(imgData),
|
||||||
|
Inline: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return SendMail(base.Cfg.Issuer, user.Email, w.String(), attach)
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ func GetJwtData(jwtToken string) (map[string]interface{}, error) {
|
|||||||
return claims, nil
|
return claims, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendMail(subject, to, htmlBody string) error {
|
func SendMail(subject, to, htmlBody string, attach *mail.File) error {
|
||||||
|
|
||||||
dataSmtp := &dbdata.SettingSmtp{}
|
dataSmtp := &dbdata.SettingSmtp{}
|
||||||
err := dbdata.SettingGet(dataSmtp)
|
err := dbdata.SettingGet(dataSmtp)
|
||||||
@@ -73,7 +73,7 @@ func SendMail(subject, to, htmlBody string) error {
|
|||||||
// - PLAIN (default)
|
// - PLAIN (default)
|
||||||
// - LOGIN
|
// - LOGIN
|
||||||
// - CRAM-MD5
|
// - CRAM-MD5
|
||||||
server.Authentication = mail.AuthPlain
|
server.Authentication = mail.AuthAuto
|
||||||
|
|
||||||
// Variable to keep alive connection
|
// Variable to keep alive connection
|
||||||
server.KeepAlive = false
|
server.KeepAlive = false
|
||||||
@@ -102,6 +102,10 @@ func SendMail(subject, to, htmlBody string) error {
|
|||||||
AddTo(to).
|
AddTo(to).
|
||||||
SetSubject(subject)
|
SetSubject(subject)
|
||||||
|
|
||||||
|
if attach != nil {
|
||||||
|
email.Attach(attach)
|
||||||
|
}
|
||||||
|
|
||||||
email.SetBody(mail.TextHTML, htmlBody)
|
email.SetBody(mail.TextHTML, htmlBody)
|
||||||
|
|
||||||
// Call Send and pass the client
|
// Call Send and pass the client
|
||||||
|
@@ -25,6 +25,7 @@ func StartAdmin() {
|
|||||||
r.Use(func(next http.Handler) http.Handler {
|
r.Use(func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
utils.SetSecureHeader(w)
|
utils.SetSecureHeader(w)
|
||||||
|
w.Header().Set("Server", "AnyLinkAdminOpenSource")
|
||||||
next.ServeHTTP(w, req)
|
next.ServeHTTP(w, req)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -96,8 +97,9 @@ func StartAdmin() {
|
|||||||
r.HandleFunc("/debug/pprof", location("/debug/pprof/")).Name("debug")
|
r.HandleFunc("/debug/pprof", location("/debug/pprof/")).Name("debug")
|
||||||
r.PathPrefix("/debug/pprof/").HandlerFunc(pprof.Index).Name("debug")
|
r.PathPrefix("/debug/pprof/").HandlerFunc(pprof.Index).Name("debug")
|
||||||
// statsviz
|
// statsviz
|
||||||
r.Path("/debug/statsviz/ws").Name("debug").HandlerFunc(statsviz.Ws)
|
srv, _ := statsviz.NewServer() // Create server or handle error
|
||||||
r.PathPrefix("/debug/statsviz/").Name("debug").Handler(statsviz.Index)
|
r.Path("/debug/statsviz/ws").Name("debug").HandlerFunc(srv.Ws())
|
||||||
|
r.PathPrefix("/debug/statsviz/").Name("debug").Handler(srv.Index())
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Info("Listen admin", base.Cfg.AdminAddr)
|
base.Info("Listen admin", base.Cfg.AdminAddr)
|
||||||
@@ -128,6 +130,7 @@ func StartAdmin() {
|
|||||||
Addr: base.Cfg.AdminAddr,
|
Addr: base.Cfg.AdminAddr,
|
||||||
Handler: r,
|
Handler: r,
|
||||||
TLSConfig: tlsConfig,
|
TLSConfig: tlsConfig,
|
||||||
|
ErrorLog: base.GetServerLog(),
|
||||||
}
|
}
|
||||||
err := srv.ListenAndServeTLS("", "")
|
err := srv.ListenAndServeTLS("", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -2,6 +2,12 @@ package base
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
APP_NAME = "AnyLink"
|
APP_NAME = "AnyLink"
|
||||||
// app版本号
|
)
|
||||||
APP_VER = "0.10.1"
|
|
||||||
|
var (
|
||||||
|
// APP_VER app版本号
|
||||||
|
APP_VER = "0.0.1"
|
||||||
|
// 提交id
|
||||||
|
CommitId string
|
||||||
|
BuildDate string
|
||||||
)
|
)
|
||||||
|
@@ -33,6 +33,7 @@ type ServerConfig struct {
|
|||||||
// LinkAddr string `json:"link_addr"`
|
// LinkAddr string `json:"link_addr"`
|
||||||
Conf string `json:"conf"`
|
Conf string `json:"conf"`
|
||||||
Profile string `json:"profile"`
|
Profile string `json:"profile"`
|
||||||
|
ProfileName string `json:"profile_name"`
|
||||||
ServerAddr string `json:"server_addr"`
|
ServerAddr string `json:"server_addr"`
|
||||||
ServerDTLSAddr string `json:"server_dtls_addr"`
|
ServerDTLSAddr string `json:"server_dtls_addr"`
|
||||||
ServerDTLS bool `json:"server_dtls"`
|
ServerDTLS bool `json:"server_dtls"`
|
||||||
@@ -45,6 +46,7 @@ type ServerConfig struct {
|
|||||||
FilesPath string `json:"files_path"`
|
FilesPath string `json:"files_path"`
|
||||||
LogPath string `json:"log_path"`
|
LogPath string `json:"log_path"`
|
||||||
LogLevel string `json:"log_level"`
|
LogLevel string `json:"log_level"`
|
||||||
|
HttpServerLog bool `json:"http_server_log"`
|
||||||
Pprof bool `json:"pprof"`
|
Pprof bool `json:"pprof"`
|
||||||
Issuer string `json:"issuer"`
|
Issuer string `json:"issuer"`
|
||||||
AdminUser string `json:"admin_user"`
|
AdminUser string `json:"admin_user"`
|
||||||
@@ -70,6 +72,7 @@ type ServerConfig struct {
|
|||||||
Mtu int `json:"mtu"`
|
Mtu int `json:"mtu"`
|
||||||
DefaultDomain string `json:"default_domain"`
|
DefaultDomain string `json:"default_domain"`
|
||||||
|
|
||||||
|
IdleTimeout int `json:"idle_timeout"` // in seconds
|
||||||
SessionTimeout int `json:"session_timeout"` // in seconds
|
SessionTimeout int `json:"session_timeout"` // in seconds
|
||||||
// AuthTimeout int `json:"auth_timeout"` // in seconds
|
// AuthTimeout int `json:"auth_timeout"` // in seconds
|
||||||
AuditInterval int `json:"audit_interval"` // in seconds
|
AuditInterval int `json:"audit_interval"` // in seconds
|
||||||
@@ -79,7 +82,8 @@ type ServerConfig struct {
|
|||||||
Compression bool `json:"compression"` // bool
|
Compression bool `json:"compression"` // bool
|
||||||
NoCompressLimit int `json:"no_compress_limit"` // int
|
NoCompressLimit int `json:"no_compress_limit"` // int
|
||||||
|
|
||||||
DisplayError bool `json:"display_error"`
|
DisplayError bool `json:"display_error"`
|
||||||
|
ExcludeExportIp bool `json:"exclude_export_ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func initServerCfg() {
|
func initServerCfg() {
|
||||||
@@ -153,6 +157,7 @@ type SCfg struct {
|
|||||||
Env string `json:"env"`
|
Env string `json:"env"`
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
|
Val interface{} `json:"default"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServerCfg2Slice() []SCfg {
|
func ServerCfg2Slice() []SCfg {
|
||||||
@@ -167,18 +172,27 @@ func ServerCfg2Slice() []SCfg {
|
|||||||
field := typ.Field(i)
|
field := typ.Field(i)
|
||||||
value := s.Field(i)
|
value := s.Field(i)
|
||||||
tag := field.Tag.Get("json")
|
tag := field.Tag.Get("json")
|
||||||
usage, env := getUsageEnv(tag)
|
usage, env, val := getUsageEnv(tag)
|
||||||
|
|
||||||
datas = append(datas, SCfg{Name: tag, Env: env, Info: usage, Data: value.Interface()})
|
datas = append(datas, SCfg{Name: tag, Env: env, Info: usage, Data: value.Interface(), Val: val})
|
||||||
}
|
}
|
||||||
|
|
||||||
return datas
|
return datas
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUsageEnv(name string) (usage, env string) {
|
func getUsageEnv(name string) (usage, env string, val interface{}) {
|
||||||
for _, v := range configs {
|
for _, v := range configs {
|
||||||
if v.Name == name {
|
if v.Name == name {
|
||||||
usage = v.Usage
|
usage = v.Usage
|
||||||
|
if v.Typ == cfgStr {
|
||||||
|
val = v.ValStr
|
||||||
|
}
|
||||||
|
if v.Typ == cfgInt {
|
||||||
|
val = v.ValInt
|
||||||
|
}
|
||||||
|
if v.Typ == cfgBool {
|
||||||
|
val = v.ValBool
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@@ -17,8 +16,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// 提交id
|
|
||||||
CommitId string
|
|
||||||
// pass明文
|
// pass明文
|
||||||
passwd string
|
passwd string
|
||||||
// 生成otp
|
// 生成otp
|
||||||
@@ -61,8 +58,28 @@ func execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !runSrv {
|
if !runSrv {
|
||||||
|
if debug {
|
||||||
|
scfgData := ServerCfg2Slice()
|
||||||
|
fmtStr := "%-18v %-23v %-20v %v\n"
|
||||||
|
fmt.Printf(fmtStr, "Name", "Env", "Value", "Info")
|
||||||
|
for _, v := range scfgData {
|
||||||
|
if v.Name == "admin_pass" || v.Name == "jwt_secret" {
|
||||||
|
v.Val = "******"
|
||||||
|
}
|
||||||
|
fmt.Printf(fmtStr, v.Name, v.Env, v.Val, v.Info)
|
||||||
|
}
|
||||||
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移动配置解析代码
|
||||||
|
conf := linkViper.GetString("conf")
|
||||||
|
linkViper.SetConfigFile(conf)
|
||||||
|
err = linkViper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
// 没有配置文件,直接报错
|
||||||
|
panic("config file err:" + err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initCmd() {
|
func initCmd() {
|
||||||
@@ -106,19 +123,6 @@ func initCmd() {
|
|||||||
|
|
||||||
cobra.OnInitialize(func() {
|
cobra.OnInitialize(func() {
|
||||||
linkViper.AutomaticEnv()
|
linkViper.AutomaticEnv()
|
||||||
conf := linkViper.GetString("conf")
|
|
||||||
|
|
||||||
_, err := os.Stat(conf)
|
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
|
||||||
// 没有配置文件,不做处理
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
linkViper.SetConfigFile(conf)
|
|
||||||
err = linkViper.ReadInConfig()
|
|
||||||
if err != nil {
|
|
||||||
panic("config file err:" + err.Error())
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +140,8 @@ func initToolCmd() *cobra.Command {
|
|||||||
toolCmd.Flags().BoolVarP(&debug, "debug", "d", false, "list the config viper.Debug() info")
|
toolCmd.Flags().BoolVarP(&debug, "debug", "d", false, "list the config viper.Debug() info")
|
||||||
|
|
||||||
toolCmd.Run = func(cmd *cobra.Command, args []string) {
|
toolCmd.Run = func(cmd *cobra.Command, args []string) {
|
||||||
|
runSrv = false
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case rev:
|
case rev:
|
||||||
printVersion()
|
printVersion()
|
||||||
@@ -154,7 +160,7 @@ func initToolCmd() *cobra.Command {
|
|||||||
pass, _ := utils.PasswordHash(passwd)
|
pass, _ := utils.PasswordHash(passwd)
|
||||||
fmt.Printf("Passwd:%s\n", pass)
|
fmt.Printf("Passwd:%s\n", pass)
|
||||||
case debug:
|
case debug:
|
||||||
linkViper.Debug()
|
// linkViper.Debug()
|
||||||
default:
|
default:
|
||||||
fmt.Println("Using [anylink tool -h] for help")
|
fmt.Println("Using [anylink tool -h] for help")
|
||||||
}
|
}
|
||||||
@@ -164,6 +170,6 @@ func initToolCmd() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printVersion() {
|
func printVersion() {
|
||||||
fmt.Printf("%s v%s build on %s [%s, %s] commit_id(%s) \n",
|
fmt.Printf("%s v%s build on %s [%s, %s] date:%s commit_id(%s)\n",
|
||||||
APP_NAME, APP_VER, runtime.Version(), runtime.GOOS, runtime.GOARCH, CommitId)
|
APP_NAME, APP_VER, runtime.Version(), runtime.GOOS, runtime.GOARCH, BuildDate, CommitId)
|
||||||
}
|
}
|
||||||
|
@@ -22,9 +22,10 @@ type config struct {
|
|||||||
var configs = []config{
|
var configs = []config{
|
||||||
{Typ: cfgStr, Name: "conf", Usage: "config file", ValStr: "./conf/server.toml", Short: "c"},
|
{Typ: cfgStr, Name: "conf", Usage: "config file", ValStr: "./conf/server.toml", Short: "c"},
|
||||||
{Typ: cfgStr, Name: "profile", Usage: "profile.xml file", ValStr: "./conf/profile.xml"},
|
{Typ: cfgStr, Name: "profile", Usage: "profile.xml file", ValStr: "./conf/profile.xml"},
|
||||||
{Typ: cfgStr, Name: "server_addr", Usage: "服务监听地址", ValStr: ":443"},
|
{Typ: cfgStr, Name: "profile_name", Usage: "profile name(用于区分不同服务端的配置)", ValStr: "anylink"},
|
||||||
|
{Typ: cfgStr, Name: "server_addr", Usage: "TCP服务监听地址(任意端口)", ValStr: ":443"},
|
||||||
{Typ: cfgBool, Name: "server_dtls", Usage: "开启DTLS", ValBool: false},
|
{Typ: cfgBool, Name: "server_dtls", Usage: "开启DTLS", ValBool: false},
|
||||||
{Typ: cfgStr, Name: "server_dtls_addr", Usage: "DTLS监听地址", ValStr: ":443"},
|
{Typ: cfgStr, Name: "server_dtls_addr", Usage: "DTLS监听地址(任意端口)", ValStr: ":443"},
|
||||||
{Typ: cfgStr, Name: "admin_addr", Usage: "后台服务监听地址", ValStr: ":8800"},
|
{Typ: cfgStr, Name: "admin_addr", Usage: "后台服务监听地址", ValStr: ":8800"},
|
||||||
{Typ: cfgBool, Name: "proxy_protocol", Usage: "TCP代理协议", ValBool: false},
|
{Typ: cfgBool, Name: "proxy_protocol", Usage: "TCP代理协议", ValBool: false},
|
||||||
{Typ: cfgStr, Name: "db_type", Usage: "数据库类型 [sqlite3 mysql postgres]", ValStr: "sqlite3"},
|
{Typ: cfgStr, Name: "db_type", Usage: "数据库类型 [sqlite3 mysql postgres]", ValStr: "sqlite3"},
|
||||||
@@ -34,7 +35,8 @@ var configs = []config{
|
|||||||
{Typ: cfgStr, Name: "files_path", Usage: "外部下载文件路径", ValStr: "./conf/files"},
|
{Typ: cfgStr, Name: "files_path", Usage: "外部下载文件路径", ValStr: "./conf/files"},
|
||||||
{Typ: cfgStr, Name: "log_path", Usage: "日志文件路径,默认标准输出", ValStr: ""},
|
{Typ: cfgStr, Name: "log_path", Usage: "日志文件路径,默认标准输出", ValStr: ""},
|
||||||
{Typ: cfgStr, Name: "log_level", Usage: "日志等级 [debug info warn error]", ValStr: "debug"},
|
{Typ: cfgStr, Name: "log_level", Usage: "日志等级 [debug info warn error]", ValStr: "debug"},
|
||||||
{Typ: cfgBool, Name: "pprof", Usage: "开启pprof", ValBool: false},
|
{Typ: cfgBool, Name: "http_server_log", Usage: "开启go标准库http.Server的日志", ValBool: false},
|
||||||
|
{Typ: cfgBool, Name: "pprof", Usage: "开启pprof", ValBool: true},
|
||||||
{Typ: cfgStr, Name: "issuer", Usage: "系统名称", ValStr: "XX公司VPN"},
|
{Typ: cfgStr, Name: "issuer", Usage: "系统名称", ValStr: "XX公司VPN"},
|
||||||
{Typ: cfgStr, Name: "admin_user", Usage: "管理用户名", ValStr: "admin"},
|
{Typ: cfgStr, Name: "admin_user", Usage: "管理用户名", ValStr: "admin"},
|
||||||
{Typ: cfgStr, Name: "admin_pass", Usage: "管理用户密码", ValStr: defaultPwd},
|
{Typ: cfgStr, Name: "admin_pass", Usage: "管理用户密码", ValStr: defaultPwd},
|
||||||
@@ -47,19 +49,20 @@ var configs = []config{
|
|||||||
{Typ: cfgStr, Name: "ipv4_start", Usage: "IPV4开始地址", ValStr: "192.168.90.100"},
|
{Typ: cfgStr, Name: "ipv4_start", Usage: "IPV4开始地址", ValStr: "192.168.90.100"},
|
||||||
{Typ: cfgStr, Name: "ipv4_end", Usage: "IPV4结束", ValStr: "192.168.90.200"},
|
{Typ: cfgStr, Name: "ipv4_end", Usage: "IPV4结束", ValStr: "192.168.90.200"},
|
||||||
{Typ: cfgStr, Name: "default_group", Usage: "默认用户组", ValStr: "one"},
|
{Typ: cfgStr, Name: "default_group", Usage: "默认用户组", ValStr: "one"},
|
||||||
{Typ: cfgStr, Name: "default_domain", Usage: "要发布的默认域", ValStr: ""},
|
{Typ: cfgStr, Name: "default_domain", Usage: "客户端dns的默认搜索域", ValStr: ""},
|
||||||
|
|
||||||
{Typ: cfgInt, Name: "ip_lease", Usage: "IP租期(秒)", ValInt: 86400},
|
{Typ: cfgInt, Name: "ip_lease", Usage: "IP租期(秒)", ValInt: 86400},
|
||||||
{Typ: cfgInt, Name: "max_client", Usage: "最大用户连接", ValInt: 200},
|
{Typ: cfgInt, Name: "max_client", Usage: "最大用户连接", ValInt: 200},
|
||||||
{Typ: cfgInt, Name: "max_user_client", Usage: "最大单用户连接", ValInt: 3},
|
{Typ: cfgInt, Name: "max_user_client", Usage: "最大单用户连接", ValInt: 3},
|
||||||
{Typ: cfgInt, Name: "cstp_keepalive", Usage: "keepalive时间(秒)", ValInt: 4},
|
{Typ: cfgInt, Name: "cstp_keepalive", Usage: "keepalive时间(秒)", ValInt: 3},
|
||||||
{Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 9},
|
{Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 20},
|
||||||
{Typ: cfgInt, Name: "mobile_keepalive", Usage: "移动端keepalive接检测时间(秒)", ValInt: 7},
|
{Typ: cfgInt, Name: "mobile_keepalive", Usage: "移动端keepalive接检测时间(秒)", ValInt: 4},
|
||||||
{Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 15},
|
{Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 60},
|
||||||
{Typ: cfgInt, Name: "mtu", Usage: "最大传输单元MTU", ValInt: 1460},
|
{Typ: cfgInt, Name: "mtu", Usage: "最大传输单元MTU", ValInt: 1460},
|
||||||
|
{Typ: cfgInt, Name: "idle_timeout", Usage: "空闲链接超时时间(秒)-超时后断开链接,0关闭此功能", ValInt: 0},
|
||||||
{Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)-用于断线重连,0永不过期", ValInt: 3600},
|
{Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)-用于断线重连,0永不过期", ValInt: 3600},
|
||||||
// {Typ: cfgInt, Name: "auth_timeout", Usage: "auth_timeout", ValInt: 0},
|
// {Typ: cfgInt, Name: "auth_timeout", Usage: "auth_timeout", ValInt: 0},
|
||||||
{Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),-1关闭", ValInt: -1},
|
{Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),-1关闭", ValInt: 600},
|
||||||
|
|
||||||
{Typ: cfgBool, Name: "show_sql", Usage: "显示sql语句,用于调试", ValBool: false},
|
{Typ: cfgBool, Name: "show_sql", Usage: "显示sql语句,用于调试", ValBool: false},
|
||||||
{Typ: cfgBool, Name: "iptables_nat", Usage: "是否自动添加NAT", ValBool: true},
|
{Typ: cfgBool, Name: "iptables_nat", Usage: "是否自动添加NAT", ValBool: true},
|
||||||
@@ -67,6 +70,7 @@ var configs = []config{
|
|||||||
{Typ: cfgInt, Name: "no_compress_limit", Usage: "低于及等于多少字节不压缩", ValInt: 256},
|
{Typ: cfgInt, Name: "no_compress_limit", Usage: "低于及等于多少字节不压缩", ValInt: 256},
|
||||||
|
|
||||||
{Typ: cfgBool, Name: "display_error", Usage: "客户端显示详细错误信息(线上环境慎开启)", ValBool: false},
|
{Typ: cfgBool, Name: "display_error", Usage: "客户端显示详细错误信息(线上环境慎开启)", ValBool: false},
|
||||||
|
{Typ: cfgBool, Name: "exclude_export_ip", Usage: "排除出口ip路由(出口ip不加密传输)", ValBool: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
var envs = map[string]string{}
|
var envs = map[string]string{}
|
||||||
|
@@ -28,6 +28,10 @@ var (
|
|||||||
logName = "anylink.log"
|
logName = "anylink.log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||||
|
}
|
||||||
|
|
||||||
// 实现 os.Writer 接口
|
// 实现 os.Writer 接口
|
||||||
type logWriter struct {
|
type logWriter struct {
|
||||||
UseStdout bool
|
UseStdout bool
|
||||||
@@ -77,15 +81,28 @@ func initLog() {
|
|||||||
baseLw.newFile()
|
baseLw.newFile()
|
||||||
baseLevel = logLevel2Int(Cfg.LogLevel)
|
baseLevel = logLevel2Int(Cfg.LogLevel)
|
||||||
baseLog = log.New(baseLw, "", log.LstdFlags|log.Lshortfile)
|
baseLog = log.New(baseLw, "", log.LstdFlags|log.Lshortfile)
|
||||||
|
|
||||||
|
serverLog = log.New(&sLogWriter{}, "[http_server]", log.LstdFlags|log.Lshortfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBaseLw() *logWriter {
|
func GetBaseLw() *logWriter {
|
||||||
return baseLw
|
return baseLw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var serverLog *log.Logger
|
||||||
|
|
||||||
|
type sLogWriter struct{}
|
||||||
|
|
||||||
|
func (w *sLogWriter) Write(p []byte) (n int, err error) {
|
||||||
|
if Cfg.HttpServerLog {
|
||||||
|
return os.Stderr.Write(p)
|
||||||
|
}
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
// 获取 log.Logger
|
// 获取 log.Logger
|
||||||
func GetBaseLog() *log.Logger {
|
func GetServerLog() *log.Logger {
|
||||||
return baseLog
|
return serverLog
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLogLevel() int {
|
func GetLogLevel() int {
|
||||||
|
@@ -50,20 +50,24 @@ func CheckModOrLoad(mod string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
if mod == "tun" || mod == "tap" {
|
if mod == "tun" || mod == "tap" {
|
||||||
_, err := os.Stat(tunPath)
|
_, err = os.Stat(tunPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// 文件存在
|
// 文件存在
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
panic("Linux tunFile is null " + tunPath)
|
// err = fmt.Errorf("[error] Linux tunFile is null %s", tunPath)
|
||||||
|
// log.Println(err)
|
||||||
|
// return
|
||||||
}
|
}
|
||||||
|
|
||||||
if InContainer {
|
if InContainer {
|
||||||
err := fmt.Errorf("Linux module %s is not loaded, please run `modprobe %s`", mod, mod)
|
err = fmt.Errorf("[error] Linux module %s is not loaded, please run `modprobe %s`", mod, mod)
|
||||||
// log.Println(err)
|
log.Println(err)
|
||||||
// return
|
return
|
||||||
panic(err)
|
// panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdstr := fmt.Sprintln("modprobe", mod)
|
cmdstr := fmt.Sprintln("modprobe", mod)
|
||||||
@@ -71,7 +75,7 @@ func CheckModOrLoad(mod string) {
|
|||||||
cmd := exec.Command("sh", "-c", cmdstr)
|
cmd := exec.Command("sh", "-c", cmdstr)
|
||||||
b, err := cmd.CombinedOutput()
|
b, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(string(b))
|
log.Println(mod, string(b))
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,15 +7,24 @@
|
|||||||
db_type = "sqlite3"
|
db_type = "sqlite3"
|
||||||
db_source = "./conf/anylink.db"
|
db_source = "./conf/anylink.db"
|
||||||
#证书文件 使用跟nginx一样的证书即可
|
#证书文件 使用跟nginx一样的证书即可
|
||||||
cert_file = "./conf/vpn_cert.crt"
|
cert_file = "./conf/vpn_cert.pem"
|
||||||
cert_key = "./conf/vpn_cert.key"
|
cert_key = "./conf/vpn_cert.key"
|
||||||
files_path = "./conf/files"
|
files_path = "./conf/files"
|
||||||
profile = "./conf/profile.xml"
|
profile = "./conf/profile.xml"
|
||||||
#日志目录,为空写入标准输出
|
#profile name(用于区分不同服务端的配置)
|
||||||
|
#客户端存放位置
|
||||||
|
#Windows 10
|
||||||
|
#%ProgramData%Cisco\Cisco AnyConnect Secure Mobility Client\Profile
|
||||||
|
#Mac Os X
|
||||||
|
#/opt/cisco/anyconnect/profile
|
||||||
|
#Linux
|
||||||
|
#/opt/cisco/anyconnect/profile
|
||||||
|
profile_name = "anylink"
|
||||||
|
#日志目录,默认为空写入标准输出
|
||||||
#log_path = "./log"
|
#log_path = "./log"
|
||||||
log_path = ""
|
log_path = ""
|
||||||
log_level = "debug"
|
log_level = "debug"
|
||||||
pprof = false
|
pprof = true
|
||||||
|
|
||||||
#系统名称
|
#系统名称
|
||||||
issuer = "XX公司VPN"
|
issuer = "XX公司VPN"
|
||||||
@@ -29,19 +38,22 @@ admin_otp = ""
|
|||||||
jwt_secret = "abcdef.0123456789.abcdef"
|
jwt_secret = "abcdef.0123456789.abcdef"
|
||||||
|
|
||||||
|
|
||||||
#服务监听地址
|
#TCP服务监听地址(任意端口)
|
||||||
server_addr = ":443"
|
server_addr = ":443"
|
||||||
#开启 DTLS, 默认关闭
|
#开启 DTLS
|
||||||
server_dtls = false
|
server_dtls = false
|
||||||
|
#UDP监听地址(任意端口)
|
||||||
server_dtls_addr = ":443"
|
server_dtls_addr = ":443"
|
||||||
#后台服务监听地址
|
#后台服务监听地址
|
||||||
admin_addr = ":8800"
|
admin_addr = ":8800"
|
||||||
#开启tcp proxy protocol协议
|
#开启tcp proxy protocol协议
|
||||||
proxy_protocol = false
|
proxy_protocol = false
|
||||||
|
|
||||||
|
#虚拟网络类型[tun macvtap tap]
|
||||||
link_mode = "tun"
|
link_mode = "tun"
|
||||||
|
|
||||||
#客户端分配的ip地址池
|
#客户端分配的ip地址池
|
||||||
|
#docker环境一般默认 eth0,其他情况根据实际网卡信息填写
|
||||||
ipv4_master = "eth0"
|
ipv4_master = "eth0"
|
||||||
ipv4_cidr = "192.168.90.0/24"
|
ipv4_cidr = "192.168.90.0/24"
|
||||||
ipv4_gateway = "192.168.90.1"
|
ipv4_gateway = "192.168.90.1"
|
||||||
@@ -49,7 +61,7 @@ ipv4_start = "192.168.90.100"
|
|||||||
ipv4_end = "192.168.90.200"
|
ipv4_end = "192.168.90.200"
|
||||||
|
|
||||||
#最大客户端数量
|
#最大客户端数量
|
||||||
max_client = 100
|
max_client = 200
|
||||||
#单个用户同时在线数量
|
#单个用户同时在线数量
|
||||||
max_user_client = 3
|
max_user_client = 3
|
||||||
#IP租期(秒)
|
#IP租期(秒)
|
||||||
@@ -59,22 +71,30 @@ ip_lease = 86400
|
|||||||
default_group = "one"
|
default_group = "one"
|
||||||
|
|
||||||
#客户端失效检测时间(秒) dpd > keepalive
|
#客户端失效检测时间(秒) dpd > keepalive
|
||||||
cstp_keepalive = 6
|
cstp_keepalive = 3
|
||||||
cstp_dpd = 10
|
cstp_dpd = 20
|
||||||
mobile_keepalive = 15
|
mobile_keepalive = 4
|
||||||
mobile_dpd = 20
|
mobile_dpd = 60
|
||||||
|
|
||||||
|
# 根据实际情况修改
|
||||||
|
#cstp_keepalive = 20
|
||||||
|
#cstp_dpd = 30
|
||||||
|
#mobile_keepalive = 40
|
||||||
|
#mobile_dpd = 60
|
||||||
|
|
||||||
#设置最大传输单元
|
#设置最大传输单元
|
||||||
mtu = 1460
|
mtu = 1460
|
||||||
|
|
||||||
# 要发布的默认域
|
# 客户端dns的默认搜索域
|
||||||
default_domain = "example.com"
|
default_domain = "example.com"
|
||||||
#default_domain = "example.com abc.example.com"
|
#default_domain = "example.com abc.example.com"
|
||||||
|
|
||||||
|
#空闲链接超时时间(秒)-超时后断开链接,0关闭此功能
|
||||||
|
idle_timeout = 0
|
||||||
#session过期时间,用于断线重连,0永不过期
|
#session过期时间,用于断线重连,0永不过期
|
||||||
session_timeout = 3600
|
session_timeout = 3600
|
||||||
auth_timeout = 0
|
#auth_timeout = 0
|
||||||
audit_interval = -1
|
audit_interval = 600
|
||||||
|
|
||||||
show_sql = false
|
show_sql = false
|
||||||
|
|
||||||
@@ -89,4 +109,5 @@ no_compress_limit = 256
|
|||||||
#客户端显示详细错误信息(线上环境慎开启)
|
#客户端显示详细错误信息(线上环境慎开启)
|
||||||
display_error = false
|
display_error = false
|
||||||
|
|
||||||
|
#排除出口ip路由(出口ip不加密传输)
|
||||||
|
exclude_export_ip = true
|
||||||
|
@@ -7,9 +7,12 @@
|
|||||||
db_type = "sqlite3"
|
db_type = "sqlite3"
|
||||||
db_source = "./conf/anylink.db"
|
db_source = "./conf/anylink.db"
|
||||||
#证书文件
|
#证书文件
|
||||||
cert_file = "./conf/vpn_cert.crt"
|
cert_file = "./conf/vpn_cert.pem"
|
||||||
cert_key = "./conf/vpn_cert.key"
|
cert_key = "./conf/vpn_cert.key"
|
||||||
files_path = "./conf/files"
|
files_path = "./conf/files"
|
||||||
|
|
||||||
|
#日志目录,默认为空写入标准输出
|
||||||
|
#log_path = "./log"
|
||||||
log_level = "debug"
|
log_level = "debug"
|
||||||
|
|
||||||
#系统名称
|
#系统名称
|
||||||
@@ -23,13 +26,24 @@ admin_pass = "$2a$10$UQ7C.EoPifDeJh6d8.31TeSPQU7hM/NOM2nixmBucJpAuXDQNqNke"
|
|||||||
admin_otp = ""
|
admin_otp = ""
|
||||||
jwt_secret = "abcdef.0123456789.abcdef"
|
jwt_secret = "abcdef.0123456789.abcdef"
|
||||||
|
|
||||||
#服务监听地址
|
#TCP服务监听地址(任意端口)
|
||||||
server_addr = ":443"
|
server_addr = ":443"
|
||||||
|
#开启 DTLS
|
||||||
|
server_dtls = false
|
||||||
|
#UDP监听地址(任意端口)
|
||||||
|
server_dtls_addr = ":443"
|
||||||
#后台服务监听地址
|
#后台服务监听地址
|
||||||
admin_addr = ":8800"
|
admin_addr = ":8800"
|
||||||
|
|
||||||
|
#最大客户端数量
|
||||||
|
max_client = 200
|
||||||
|
#单个用户同时在线数量
|
||||||
|
max_user_client = 3
|
||||||
|
|
||||||
|
#虚拟网络类型[tun macvtap]
|
||||||
|
link_mode = "tun"
|
||||||
#客户端分配的ip地址池
|
#客户端分配的ip地址池
|
||||||
|
#docker环境一般默认 eth0,其他情况根据实际网卡信息填写
|
||||||
ipv4_master = "eth0"
|
ipv4_master = "eth0"
|
||||||
ipv4_cidr = "192.168.90.0/24"
|
ipv4_cidr = "192.168.90.0/24"
|
||||||
ipv4_gateway = "192.168.90.1"
|
ipv4_gateway = "192.168.90.1"
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIF9jCCBN6gAwIBAgIQAuUy6Rv6Bo3nDXn5FackbDANBgkqhkiG9w0BAQsFADBu
|
|
||||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
|
||||||
d3cuZGlnaWNlcnQuY29tMS0wKwYDVQQDEyRFbmNyeXB0aW9uIEV2ZXJ5d2hlcmUg
|
|
||||||
RFYgVExTIENBIC0gRzEwHhcNMjMwMTAzMDAwMDAwWhcNMjQwMTAzMjM1OTU5WjAc
|
|
||||||
MRowGAYDVQQDExF2cG4udGVzdC52cWlsdS5jbjCCASIwDQYJKoZIhvcNAQEBBQAD
|
|
||||||
ggEPADCCAQoCggEBANJAJPYBvOP/7v8SgMIkVLIulN/ziPALvFcEwVnQDImUIky8
|
|
||||||
4udy0fmvJ2E3E3NL6Qv14ZHDGtH7CafukimNWTT2BVmQBYiO1ZlUkHcHUX4IoYEh
|
|
||||||
egdy2xw0WwknJWTOyvkRkeDhtT9QUpA/zeemS4q1TG95zRDf5htUR4OMZXsZpkQ2
|
|
||||||
bkSgnLtdyUmw2nhfSWgsD9fbwr6WnOx/swsUe52N3sIDZ6JTgn3N7xeT3/lVJKVN
|
|
||||||
wyYkZldialmRzrs6btr3mmnqpWObcc4FvKr/CLmoOSXl0I1wWsr+HnQ4X9hHsJUk
|
|
||||||
jk3EZKfhH3mM37HF8apqztb6WjC3R96Zam6Z8bMCAwEAAaOCAuAwggLcMB8GA1Ud
|
|
||||||
IwQYMBaAFFV0T7JyT/VgulDR1+ZRXJoBhxrXMB0GA1UdDgQWBBSUpPcW3emC2l0o
|
|
||||||
q6qRBOBDMjQ2rDAcBgNVHREEFTATghF2cG4udGVzdC52cWlsdS5jbjAOBgNVHQ8B
|
|
||||||
Af8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMD4GA1UdIAQ3
|
|
||||||
MDUwMwYGZ4EMAQIBMCkwJwYIKwYBBQUHAgEWG2h0dHA6Ly93d3cuZGlnaWNlcnQu
|
|
||||||
Y29tL0NQUzCBgAYIKwYBBQUHAQEEdDByMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz
|
|
||||||
cC5kaWdpY2VydC5jb20wSgYIKwYBBQUHMAKGPmh0dHA6Ly9jYWNlcnRzLmRpZ2lj
|
|
||||||
ZXJ0LmNvbS9FbmNyeXB0aW9uRXZlcnl3aGVyZURWVExTQ0EtRzEuY3J0MAkGA1Ud
|
|
||||||
EwQCMAAwggF9BgorBgEEAdZ5AgQCBIIBbQSCAWkBZwB2AO7N0GTV2xrOxVy3nbTN
|
|
||||||
E6Iyh0Z8vOzew1FIWUZxH7WbAAABhXXkyXMAAAQDAEcwRQIgVhLvLOPcW0V1xhBv
|
|
||||||
5KSeqGHbAnRVhew3kutV3Bu1x+ICIQCbYjRtmkDo1hx6p0YNdNfkZ3N5u+syVjwH
|
|
||||||
Al3a9NpVxgB1AEiw42vapkc0D+VqAvqdMOscUgHLVt0sgdm7v6s52IRzAAABhXXk
|
|
||||||
yY4AAAQDAEYwRAIgcuscG2kkSGNvAsVH9CAtXjNUwk9UJriY0+3OtQ4WVrMCIAsC
|
|
||||||
CkqEI1Ek5M26yrWt0Q7+u+UZ8rXhfYu3kcMMq7PVAHYAO1N3dT4tuYBOizBbBv5A
|
|
||||||
O2fYT8P0x70ADS1yb+H61BcAAAGFdeTJkAAABAMARzBFAiAEJbJTN8hrRUZ6UaaD
|
|
||||||
2TlyDQfzUvTkex0XGT6PGKHkagIhAJ+Kg6tdt/csKde2vdweu+dT01fzg/fq4q3o
|
|
||||||
mjfPhFm1MA0GCSqGSIb3DQEBCwUAA4IBAQAKFTUHbpgKsXARCBIIfEZGqkOvaafm
|
|
||||||
QaoNodc6cj0+LJCbuMzrTlkzmII0X/U52MBG8JCEIO8BPe5R4NIFqqaE066zQANq
|
|
||||||
HOsROOJi2A+WTTZcSEHbH3uhdVwcEQHvDzaOEEJc9Ilz6pdYsrv+trOmeR5PeIxv
|
|
||||||
t1jQacSwN1z6z0N4CRjBpePV/9nwETkEaKjQuXSoYlN+pczK/4nX2W9+E/OnwtZs
|
|
||||||
ScyFffPtTLHf1u4eSYuBT/AdwaKHXetxWzh98GP9LRfQhm63Gs+/WcloYl489dG/
|
|
||||||
FOFjch2TdmrPcUwxxGEbbPt3zXRxSVlzvIaf4gTUl2+PsKwbKy/w4OLS
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEqjCCA5KgAwIBAgIQAnmsRYvBskWr+YBTzSybsTANBgkqhkiG9w0BAQsFADBh
|
|
||||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
|
||||||
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
|
||||||
QTAeFw0xNzExMjcxMjQ2MTBaFw0yNzExMjcxMjQ2MTBaMG4xCzAJBgNVBAYTAlVT
|
|
||||||
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
|
|
||||||
b20xLTArBgNVBAMTJEVuY3J5cHRpb24gRXZlcnl3aGVyZSBEViBUTFMgQ0EgLSBH
|
|
||||||
MTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALPeP6wkab41dyQh6mKc
|
|
||||||
oHqt3jRIxW5MDvf9QyiOR7VfFwK656es0UFiIb74N9pRntzF1UgYzDGu3ppZVMdo
|
|
||||||
lbxhm6dWS9OK/lFehKNT0OYI9aqk6F+U7cA6jxSC+iDBPXwdF4rs3KRyp3aQn6pj
|
|
||||||
pp1yr7IB6Y4zv72Ee/PlZ/6rK6InC6WpK0nPVOYR7n9iDuPe1E4IxUMBH/T33+3h
|
|
||||||
yuH3dvfgiWUOUkjdpMbyxX+XNle5uEIiyBsi4IvbcTCh8ruifCIi5mDXkZrnMT8n
|
|
||||||
wfYCV6v6kDdXkbgGRLKsR4pucbJtbKqIkUGxuZI2t7pfewKRc5nWecvDBZf3+p1M
|
|
||||||
pA8CAwEAAaOCAU8wggFLMB0GA1UdDgQWBBRVdE+yck/1YLpQ0dfmUVyaAYca1zAf
|
|
||||||
BgNVHSMEGDAWgBQD3lA1VtFMu2bwo+IbG8OXsj3RVTAOBgNVHQ8BAf8EBAMCAYYw
|
|
||||||
HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBIGA1UdEwEB/wQIMAYBAf8C
|
|
||||||
AQAwNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdp
|
|
||||||
Y2VydC5jb20wQgYDVR0fBDswOTA3oDWgM4YxaHR0cDovL2NybDMuZGlnaWNlcnQu
|
|
||||||
Y29tL0RpZ2lDZXJ0R2xvYmFsUm9vdENBLmNybDBMBgNVHSAERTBDMDcGCWCGSAGG
|
|
||||||
/WwBAjAqMCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BT
|
|
||||||
MAgGBmeBDAECATANBgkqhkiG9w0BAQsFAAOCAQEAK3Gp6/aGq7aBZsxf/oQ+TD/B
|
|
||||||
SwW3AU4ETK+GQf2kFzYZkby5SFrHdPomunx2HBzViUchGoofGgg7gHW0W3MlQAXW
|
|
||||||
M0r5LUvStcr82QDWYNPaUy4taCQmyaJ+VB+6wxHstSigOlSNF2a6vg4rgexixeiV
|
|
||||||
4YSB03Yqp2t3TeZHM9ESfkus74nQyW7pRGezj+TC44xCagCQQOzzNmzEAP2SnCrJ
|
|
||||||
sNE2DpRVMnL8J6xBRdjmOsC3N6cQuKuRXbzByVBjCqAA8t1L0I+9wXJerLPyErjy
|
|
||||||
rMKWaBFLmfK/AHNF4ZihwPGOc7w6UHczBZXH5RFzJNnww+WnKuTPI0HfnVH8lg==
|
|
||||||
-----END CERTIFICATE-----
|
|
@@ -1,27 +1,28 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
-----BEGIN PRIVATE KEY-----
|
||||||
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
|
||||||
-----END RSA PRIVATE KEY-----
|
Cd/yRpaOSMPbqKO1OOSn
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
|
67
server/conf/vpn_cert.pem
Normal file
67
server/conf/vpn_cert.pem
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
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
|
||||||
|
H7pWcFY99X5nMwJoDDBYomY=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
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
|
||||||
|
-----END CERTIFICATE-----
|
@@ -1,6 +1,7 @@
|
|||||||
package dbdata
|
package dbdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bjdgyc/anylink/base"
|
"github.com/bjdgyc/anylink/base"
|
||||||
@@ -101,22 +102,11 @@ func addInitData() error {
|
|||||||
|
|
||||||
// SettingDnsProvider
|
// SettingDnsProvider
|
||||||
provider := &SettingLetsEncrypt{
|
provider := &SettingLetsEncrypt{
|
||||||
Domain: "vpn.xxx.com",
|
Domain: "vpn.xxx.com",
|
||||||
Legomail: "legomail",
|
Legomail: "legomail",
|
||||||
Name: "aliyun",
|
Name: "aliyun",
|
||||||
Renew: false,
|
Renew: false,
|
||||||
DNSProvider: DNSProvider{
|
DNSProvider: DNSProvider{},
|
||||||
AliYun: struct {
|
|
||||||
APIKey string `json:"apiKey"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
}{APIKey: "", SecretKey: ""},
|
|
||||||
TXCloud: struct {
|
|
||||||
SecretID string `json:"secretId"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
}{SecretID: "", SecretKey: ""},
|
|
||||||
CfCloud: struct {
|
|
||||||
AuthToken string `json:"authToken"`
|
|
||||||
}{AuthToken: ""}},
|
|
||||||
}
|
}
|
||||||
err = SettingSessAdd(sess, provider)
|
err = SettingSessAdd(sess, provider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -132,6 +122,7 @@ func addInitData() error {
|
|||||||
other := &SettingOther{
|
other := &SettingOther{
|
||||||
LinkAddr: "vpn.xx.com",
|
LinkAddr: "vpn.xx.com",
|
||||||
Banner: "您已接入公司网络,请按照公司规定使用。\n请勿进行非工作下载及视频行为!",
|
Banner: "您已接入公司网络,请按照公司规定使用。\n请勿进行非工作下载及视频行为!",
|
||||||
|
Homecode: http.StatusOK,
|
||||||
Homeindex: "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。",
|
Homeindex: "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。",
|
||||||
AccountMail: accountMail,
|
AccountMail: accountMail,
|
||||||
}
|
}
|
||||||
@@ -153,7 +144,7 @@ func addInitData() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g1 := Group{
|
g1 := Group{
|
||||||
Name: "ops",
|
Name: "all",
|
||||||
AllowLan: true,
|
AllowLan: true,
|
||||||
ClientDns: []ValData{{Val: "114.114.114.114"}},
|
ClientDns: []ValData{{Val: "114.114.114.114"}},
|
||||||
RouteInclude: []ValData{{Val: All}},
|
RouteInclude: []ValData{{Val: All}},
|
||||||
@@ -164,6 +155,18 @@ func addInitData() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g2 := Group{
|
||||||
|
Name: "ops",
|
||||||
|
AllowLan: true,
|
||||||
|
ClientDns: []ValData{{Val: "114.114.114.114"}},
|
||||||
|
RouteInclude: []ValData{{Val: "10.0.0.0/8"}},
|
||||||
|
Status: 1,
|
||||||
|
}
|
||||||
|
err = SetGroup(&g2)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,17 +183,22 @@ const accountMail = `<p>您好:</p>
|
|||||||
用户PIN码: <b>{{.PinCode}}</b> <br/>
|
用户PIN码: <b>{{.PinCode}}</b> <br/>
|
||||||
<!--
|
<!--
|
||||||
用户动态码(3天后失效):<br/>
|
用户动态码(3天后失效):<br/>
|
||||||
<img src="{{.OtpImg}}"/>
|
<img src="{{.OtpImg}}"/><br/>
|
||||||
|
|
||||||
|
用户动态码(请妥善保存):<br/>
|
||||||
|
<img src="{{.OtpImgBase64}}"/><br/>
|
||||||
|
|
||||||
|
下面是兼容 gmail 的写法
|
||||||
-->
|
-->
|
||||||
用户动态码(请妥善保存):<br/>
|
用户动态码(请妥善保存):<br/>
|
||||||
<img src="{{.OtpImgBase64}}"/>
|
<img src="cid:userOtpQr.png" alt="userOtpQr" /><br/>
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
使用说明:
|
使用说明:
|
||||||
<ul>
|
<ul>
|
||||||
<li>请使用OTP软件扫描动态码二维码</li>
|
<li>请使用OTP软件扫描动态码二维码</li>
|
||||||
<li>然后使用anyconnect客户端进行登陆</li>
|
<li>然后使用anyconnect客户端进行登陆</li>
|
||||||
<li>登陆密码为 【PIN码+动态码】</li>
|
<li>登陆密码为 【PIN码+动态码】(中间没有+号)</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
|
@@ -75,6 +75,11 @@ func Find(data interface{}, limit, page int) error {
|
|||||||
return xdb.Limit(limit, start).Find(data)
|
return xdb.Limit(limit, start).Find(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FindWhereCount(data interface{}, where string, args ...interface{}) int {
|
||||||
|
n, _ := xdb.Where(where, args...).Count(data)
|
||||||
|
return int(n)
|
||||||
|
}
|
||||||
|
|
||||||
func FindWhere(data interface{}, limit int, page int, where string, args ...interface{}) error {
|
func FindWhere(data interface{}, limit int, page int, where string, args ...interface{}) error {
|
||||||
if limit == 0 {
|
if limit == 0 {
|
||||||
return xdb.Where(where, args...).Find(data)
|
return xdb.Where(where, args...).Find(data)
|
||||||
|
@@ -29,6 +29,7 @@ type SettingAuditLog struct {
|
|||||||
type SettingOther struct {
|
type SettingOther struct {
|
||||||
LinkAddr string `json:"link_addr"`
|
LinkAddr string `json:"link_addr"`
|
||||||
Banner string `json:"banner"`
|
Banner string `json:"banner"`
|
||||||
|
Homecode int `json:"homecode"`
|
||||||
Homeindex string `json:"homeindex"`
|
Homeindex string `json:"homeindex"`
|
||||||
AccountMail string `json:"account_mail"`
|
AccountMail string `json:"account_mail"`
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,7 @@ func SettingSet(data interface{}) error {
|
|||||||
|
|
||||||
func SettingGet(data interface{}) error {
|
func SettingGet(data interface{}) error {
|
||||||
name := StructName(data)
|
name := StructName(data)
|
||||||
s := &Setting{Name: name}
|
s := &Setting{}
|
||||||
err := One("name", name, s)
|
err := One("name", name, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@@ -186,7 +186,7 @@ func checkOtp(name, otp, secret string) bool {
|
|||||||
|
|
||||||
totp := gotp.NewDefaultTOTP(secret)
|
totp := gotp.NewDefaultTOTP(secret)
|
||||||
unix := time.Now().Unix()
|
unix := time.Now().Unix()
|
||||||
verify := totp.Verify(otp, int(unix))
|
verify := totp.Verify(otp, unix)
|
||||||
|
|
||||||
return verify
|
return verify
|
||||||
}
|
}
|
||||||
|
@@ -12,16 +12,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UserAuthFail = 0 // 认证失败
|
UserAuthFail = 0 // 认证失败
|
||||||
UserAuthSuccess = 1 // 认证成功
|
UserAuthSuccess = 1 // 认证成功
|
||||||
UserConnected = 2 // 连线成功
|
UserConnected = 2 // 连线成功
|
||||||
UserLogout = 3 // 用户登出
|
UserLogout = 3 // 用户登出
|
||||||
UserLogoutLose = 0 // 用户掉线
|
UserLogoutLose = 0 // 用户掉线
|
||||||
UserLogoutBanner = 1 // 用户banner弹窗取消
|
UserLogoutBanner = 1 // 用户banner弹窗取消
|
||||||
UserLogoutClient = 2 // 用户主动登出
|
UserLogoutClient = 2 // 用户主动登出
|
||||||
UserLogoutTimeout = 3 // 用户超时登出
|
UserLogoutTimeout = 3 // 用户超时登出
|
||||||
UserLogoutAdmin = 4 // 账号被管理员踢下线
|
UserLogoutAdmin = 4 // 账号被管理员踢下线
|
||||||
UserLogoutExpire = 5 // 账号过期被踢下线
|
UserLogoutExpire = 5 // 账号过期被踢下线
|
||||||
|
UserIdleTimeout = 6 // 用户空闲链接超时
|
||||||
|
UserLogoutOneAdmin = 7 // 账号被管理员一键下线
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserActLogProcess struct {
|
type UserActLogProcess struct {
|
||||||
@@ -56,12 +59,14 @@ var (
|
|||||||
3: "AnyLink",
|
3: "AnyLink",
|
||||||
},
|
},
|
||||||
InfoOps: []string{ // 信息
|
InfoOps: []string{ // 信息
|
||||||
UserLogoutLose: "用户掉线",
|
UserLogoutLose: "用户掉线",
|
||||||
UserLogoutBanner: "用户取消弹窗/客户端发起的logout",
|
UserLogoutBanner: "用户取消弹窗/客户端发起的logout",
|
||||||
UserLogoutClient: "用户/客户端主动断开",
|
UserLogoutClient: "用户/客户端主动断开",
|
||||||
UserLogoutTimeout: "Session过期被踢下线",
|
UserLogoutTimeout: "Session过期被踢下线",
|
||||||
UserLogoutAdmin: "账号被管理员踢下线",
|
UserLogoutAdmin: "账号被管理员踢下线",
|
||||||
UserLogoutExpire: "账号过期被踢下线",
|
UserLogoutExpire: "账号过期被踢下线",
|
||||||
|
UserIdleTimeout: "用户空闲链接超时",
|
||||||
|
UserLogoutOneAdmin: "账号被管理员一键下线",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -124,6 +129,9 @@ func (ua *UserActLogProcess) GetStatusOpsWithTag() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ua *UserActLogProcess) GetInfoOpsById(id uint8) string {
|
func (ua *UserActLogProcess) GetInfoOpsById(id uint8) string {
|
||||||
|
if int(id) >= len(ua.InfoOps) {
|
||||||
|
return "未知的信息类型"
|
||||||
|
}
|
||||||
return ua.InfoOps[id]
|
return ua.InfoOps[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +145,7 @@ func (ua *UserActLogProcess) ParseUserAgent(userAgent string) (os_idx, client_id
|
|||||||
os_idx = 0
|
os_idx = 0
|
||||||
if strings.Contains(userAgent, "windows") {
|
if strings.Contains(userAgent, "windows") {
|
||||||
os_idx = 1
|
os_idx = 1
|
||||||
} else if strings.Contains(userAgent, "mac os") || strings.Contains(userAgent, "darwin_i386") {
|
} else if strings.Contains(userAgent, "mac os") || strings.Contains(userAgent, "darwin_i386") || strings.Contains(userAgent, "darwin_amd64") || strings.Contains(userAgent, "darwin_arm64") {
|
||||||
os_idx = 2
|
os_idx = 2
|
||||||
} else if strings.Contains(userAgent, "darwin_arm") || strings.Contains(userAgent, "apple") {
|
} else if strings.Contains(userAgent, "darwin_arm") || strings.Contains(userAgent, "apple") {
|
||||||
os_idx = 5
|
os_idx = 5
|
||||||
|
135
server/go.mod
135
server/go.mod
@@ -1,103 +1,108 @@
|
|||||||
module github.com/bjdgyc/anylink
|
module github.com/bjdgyc/anylink
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/arl/statsviz v0.5.1
|
github.com/arl/statsviz v0.6.0
|
||||||
github.com/deckarep/golang-set v1.8.0
|
github.com/deckarep/golang-set v1.8.0
|
||||||
github.com/go-acme/lego/v4 v4.10.2
|
github.com/go-acme/lego/v4 v4.15.0
|
||||||
github.com/go-co-op/gocron v1.17.0
|
github.com/go-co-op/gocron v1.37.0
|
||||||
github.com/go-ldap/ldap v3.0.3+incompatible
|
github.com/go-ldap/ldap v3.0.3+incompatible
|
||||||
github.com/go-sql-driver/mysql v1.6.0
|
github.com/go-sql-driver/mysql v1.8.0
|
||||||
github.com/gocarina/gocsv v0.0.0-20220712153207-8b2118da4570
|
github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a
|
||||||
github.com/golang-jwt/jwt/v4 v4.2.0
|
github.com/golang-jwt/jwt/v4 v4.5.0
|
||||||
github.com/google/gopacket v1.1.19
|
github.com/google/gopacket v1.1.19
|
||||||
github.com/gorilla/handlers v1.5.1
|
github.com/gorilla/handlers v1.5.2
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/ivpusic/grpool v1.0.0
|
github.com/ivpusic/grpool v1.0.0
|
||||||
github.com/lanrenwo/lzsgo v0.0.2
|
github.com/lanrenwo/lzsgo v0.0.2
|
||||||
github.com/lib/pq v1.10.2
|
github.com/lib/pq v1.10.9
|
||||||
github.com/mattn/go-sqlite3 v1.14.9
|
github.com/mattn/go-sqlite3 v1.14.22
|
||||||
github.com/orcaman/concurrent-map v1.0.0
|
github.com/orcaman/concurrent-map v1.0.0
|
||||||
github.com/pion/dtls/v2 v2.2.7
|
github.com/pion/dtls/v2 v2.2.10
|
||||||
github.com/pion/logging v0.2.2
|
github.com/pion/logging v0.2.2
|
||||||
github.com/pires/go-proxyproto v0.6.2
|
github.com/pires/go-proxyproto v0.7.0
|
||||||
github.com/shirou/gopsutil v3.21.7+incompatible
|
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091
|
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091
|
||||||
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
|
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
|
||||||
github.com/spf13/cast v1.3.1
|
github.com/spf13/cast v1.6.0
|
||||||
github.com/spf13/cobra v1.2.1
|
github.com/spf13/cobra v1.8.0
|
||||||
github.com/spf13/viper v1.8.1
|
github.com/spf13/viper v1.18.2
|
||||||
github.com/stretchr/testify v1.8.3
|
github.com/stretchr/testify v1.8.4
|
||||||
github.com/xhit/go-simple-mail/v2 v2.10.0
|
github.com/xhit/go-simple-mail/v2 v2.16.0
|
||||||
github.com/xlzd/gotp v0.0.0-20181030022105-c8557ba2c119
|
github.com/xlzd/gotp v0.1.0
|
||||||
github.com/xuri/excelize/v2 v2.6.1
|
github.com/xuri/excelize/v2 v2.8.1
|
||||||
go.uber.org/atomic v1.10.0
|
golang.org/x/crypto v0.21.0
|
||||||
golang.org/x/crypto v0.8.0
|
golang.org/x/net v0.22.0
|
||||||
golang.org/x/net v0.9.0
|
golang.org/x/text v0.14.0
|
||||||
golang.org/x/text v0.9.0
|
golang.org/x/time v0.5.0
|
||||||
golang.org/x/time v0.3.0
|
layeh.com/radius v0.0.0-20231213012653-1006025d24f8
|
||||||
layeh.com/radius v0.0.0-20210819152912-ad72663a72ab
|
xorm.io/xorm v1.3.8
|
||||||
xorm.io/xorm v1.3.2
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1755 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
github.com/aliyun/alibaba-cloud-sdk-go v1.62.690 // indirect
|
||||||
github.com/cloudflare/cloudflare-go v0.49.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.1 // indirect
|
github.com/cloudflare/cloudflare-go v0.89.0 // indirect
|
||||||
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
|
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
|
||||||
|
github.com/go-test/deep v1.1.0 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
|
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/miekg/dns v1.1.58 // indirect
|
||||||
github.com/miekg/dns v1.1.50 // indirect
|
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
||||||
github.com/pion/transport/v2 v2.2.1 // indirect
|
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pion/transport/v2 v2.2.4 // indirect
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.490 // indirect
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.490 // indirect
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
golang.org/x/mod v0.8.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
golang.org/x/tools v0.6.0 // indirect
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.873 // indirect
|
||||||
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.873 // indirect
|
||||||
|
github.com/toorop/go-dkim v0.0.0-20240103092955-90b7d1423f92 // indirect
|
||||||
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||||
|
go.uber.org/atomic v1.11.0 // indirect
|
||||||
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
|
||||||
|
golang.org/x/mod v0.16.0 // indirect
|
||||||
|
golang.org/x/tools v0.19.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
github.com/coreos/go-iptables v0.7.0
|
||||||
github.com/coreos/go-iptables v0.6.0
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/go-ole/go-ole v1.2.5 // indirect
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
github.com/goccy/go-json v0.8.1 // indirect
|
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/gorilla/websocket v1.4.2 // indirect
|
github.com/gorilla/websocket v1.5.1 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/magiconair/properties v1.8.5 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||||
github.com/pelletier/go-toml v1.9.3 // indirect
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
||||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||||
github.com/richardlehane/msoleps v1.0.3 // indirect
|
github.com/richardlehane/msoleps v1.0.3 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/spf13/afero v1.6.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/subosito/gotenv v1.2.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
github.com/syndtr/goleveldb v1.0.0 // indirect
|
github.com/syndtr/goleveldb v1.0.0 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.7 // indirect
|
github.com/tklauser/go-sysconf v0.3.13 // indirect
|
||||||
github.com/tklauser/numcpus v0.2.3 // indirect
|
github.com/tklauser/numcpus v0.7.0 // indirect
|
||||||
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
|
github.com/xuri/efp v0.0.0-20231025114914-d1ff6096ae53 // indirect
|
||||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
|
github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05 // indirect
|
||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/sys v0.18.0 // indirect
|
||||||
golang.org/x/sys v0.7.0 // indirect
|
|
||||||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
|
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
|
||||||
gopkg.in/ini.v1 v1.66.6 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect
|
xorm.io/builder v0.3.13 // indirect
|
||||||
)
|
)
|
||||||
|
1256
server/go.sum
1256
server/go.sum
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,10 @@ func startDtls() {
|
|||||||
|
|
||||||
logf := logging.NewDefaultLoggerFactory()
|
logf := logging.NewDefaultLoggerFactory()
|
||||||
logf.Writer = base.GetBaseLw()
|
logf.Writer = base.GetBaseLw()
|
||||||
// logf.DefaultLogLevel = logging.LogLevelTrace
|
|
||||||
logf.DefaultLogLevel = logging.LogLevelInfo
|
logf.DefaultLogLevel = logging.LogLevelInfo
|
||||||
|
if base.GetLogLevel() == base.LogLevelTrace {
|
||||||
|
// logf.DefaultLogLevel = logging.LogLevelTrace
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/pion/dtls/pull/369
|
// https://github.com/pion/dtls/pull/369
|
||||||
sessStore := &sessionStore{}
|
sessStore := &sessionStore{}
|
||||||
|
@@ -46,10 +46,11 @@ func LinkAuth(w http.ResponseWriter, r *http.Request) {
|
|||||||
cr := ClientRequest{}
|
cr := ClientRequest{}
|
||||||
err = xml.Unmarshal(body, &cr)
|
err = xml.Unmarshal(body, &cr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
base.Error(err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// fmt.Printf("%+v \n", cr)
|
base.Trace(fmt.Sprintf("%+v \n", cr))
|
||||||
// setCommonHeader(w)
|
// setCommonHeader(w)
|
||||||
if cr.Type == "logout" {
|
if cr.Type == "logout" {
|
||||||
// 退出删除session信息
|
// 退出删除session信息
|
||||||
@@ -137,10 +138,10 @@ func LinkAuth(w http.ResponseWriter, r *http.Request) {
|
|||||||
other := &dbdata.SettingOther{}
|
other := &dbdata.SettingOther{}
|
||||||
_ = dbdata.SettingGet(other)
|
_ = dbdata.SettingGet(other)
|
||||||
rd := RequestData{SessionId: sess.Sid, SessionToken: sess.Sid + "@" + sess.Token,
|
rd := RequestData{SessionId: sess.Sid, SessionToken: sess.Sid + "@" + sess.Token,
|
||||||
Banner: other.Banner, ProfileHash: profileHash}
|
Banner: other.Banner, ProfileName: base.Cfg.ProfileName, ProfileHash: profileHash}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
tplRequest(tpl_complete, w, rd)
|
tplRequest(tpl_complete, w, rd)
|
||||||
base.Debug("login", cr.Auth.Username, userAgent)
|
base.Info("login", cr.Auth.Username, userAgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -157,7 +158,7 @@ func tplRequest(typ int, w io.Writer, data RequestData) {
|
|||||||
|
|
||||||
if data.Banner != "" {
|
if data.Banner != "" {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
xml.EscapeText(buf, []byte(data.Banner))
|
_ = xml.EscapeText(buf, []byte(data.Banner))
|
||||||
data.Banner = buf.String()
|
data.Banner = buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +176,7 @@ type RequestData struct {
|
|||||||
SessionId string
|
SessionId string
|
||||||
SessionToken string
|
SessionToken string
|
||||||
Banner string
|
Banner string
|
||||||
|
ProfileName string
|
||||||
ProfileHash string
|
ProfileHash string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +229,7 @@ var auth_complete = `<?xml version="1.0" encoding="UTF-8"?>
|
|||||||
<vpn-profile-manifest>
|
<vpn-profile-manifest>
|
||||||
<vpn rev="1.0">
|
<vpn rev="1.0">
|
||||||
<file type="profile" service-type="user">
|
<file type="profile" service-type="user">
|
||||||
<uri>/profile.xml</uri>
|
<uri>/profile_{{.ProfileName}}.xml</uri>
|
||||||
<hash type="sha1">{{.ProfileHash}}</hash>
|
<hash type="sha1">{{.ProfileHash}}</hash>
|
||||||
</file>
|
</file>
|
||||||
</vpn>
|
</vpn>
|
||||||
|
@@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"log"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/bjdgyc/anylink/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
const BufferSize = 2048
|
const BufferSize = 2048
|
||||||
@@ -46,7 +47,7 @@ func execCmd(cmdStrs []string) error {
|
|||||||
cmd := exec.Command("sh", "-c", cmdStr)
|
cmd := exec.Command("sh", "-c", cmdStr)
|
||||||
b, err := cmd.CombinedOutput()
|
b, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(string(b))
|
base.Error(cmdStr, string(b))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,10 +21,13 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
n int
|
n int
|
||||||
dataLen uint16
|
dataLen uint16
|
||||||
dead = time.Duration(cSess.CstpDpd+5) * time.Second
|
dead = time.Second * time.Duration(cSess.CstpDpd+5)
|
||||||
|
idle = int64(base.Cfg.IdleTimeout)
|
||||||
|
checkIdle = base.Cfg.IdleTimeout > 0
|
||||||
|
lastTime int64
|
||||||
)
|
)
|
||||||
|
|
||||||
go cstpWrite(conn, bufRW, cSess)
|
go cstpWrite(conn, bufRW, cSess)
|
||||||
@@ -34,14 +37,14 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
|
|||||||
// 设置超时限制
|
// 设置超时限制
|
||||||
err = conn.SetReadDeadline(utils.NowSec().Add(dead))
|
err = conn.SetReadDeadline(utils.NowSec().Add(dead))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error("SetDeadline: ", cSess.Username, err)
|
base.Error("SetDeadline: ", cSess.Username, cSess.IpAddr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// hdata := make([]byte, BufferSize)
|
// hdata := make([]byte, BufferSize)
|
||||||
pl := getPayload()
|
pl := getPayload()
|
||||||
n, err = bufRW.Read(pl.Data)
|
n, err = bufRW.Read(pl.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error("read hdata: ", cSess.Username, err)
|
base.Warn("read hdata: ", cSess.Username, cSess.IpAddr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,19 +57,30 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
|
|||||||
switch pl.Data[6] {
|
switch pl.Data[6] {
|
||||||
case 0x07: // KEEPALIVE
|
case 0x07: // KEEPALIVE
|
||||||
// do nothing
|
// do nothing
|
||||||
// base.Debug("recv keepalive", cSess.IpAddr)
|
base.Trace("recv LinkCstp Keepalive", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
|
// 判断超时时间
|
||||||
|
if checkIdle {
|
||||||
|
lastTime = cSess.LastDataTime.Load()
|
||||||
|
if lastTime < (utils.NowSec().Unix() - idle) {
|
||||||
|
base.Warn("IdleTimeout", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), "lastTime", lastTime)
|
||||||
|
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserIdleTimeout)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
case 0x05: // DISCONNECT
|
case 0x05: // DISCONNECT
|
||||||
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
||||||
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr)
|
base.Info("DISCONNECT", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, string(pl.Data[9:n]))
|
||||||
|
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserLogoutClient)
|
||||||
return
|
return
|
||||||
case 0x03: // DPD-REQ
|
case 0x03: // DPD-REQ
|
||||||
// base.Debug("recv DPD-REQ", cSess.IpAddr)
|
base.Trace("recv LinkCstp DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n])
|
||||||
pl.PType = 0x04
|
pl.PType = 0x04
|
||||||
|
// pl.Data = pl.Data[:n]
|
||||||
if payloadOutCstp(cSess, pl) {
|
if payloadOutCstp(cSess, pl) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 0x04:
|
case 0x04:
|
||||||
// log.Println("recv DPD-RESP")
|
base.Trace("recv LinkCstp DPD-RESP", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
case 0x08: // decompress
|
case 0x08: // decompress
|
||||||
if cSess.CstpPickCmp == nil {
|
if cSess.CstpPickCmp == nil {
|
||||||
continue
|
continue
|
||||||
@@ -98,6 +112,8 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
|
|||||||
if payloadIn(cSess, pl) {
|
if payloadIn(cSess, pl) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 只记录返回正确的数据时间
|
||||||
|
cSess.LastDataTime.Store(utils.NowSec().Unix())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +176,7 @@ func cstpWrite(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessi
|
|||||||
|
|
||||||
n, err = conn.Write(pl.Data)
|
n, err = conn.Write(pl.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error("write err", cSess.Username, err)
|
base.Warn("write err", cSess.Username, cSess.IpAddr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,14 +36,14 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
|
|||||||
for {
|
for {
|
||||||
err = conn.SetReadDeadline(utils.NowSec().Add(dead))
|
err = conn.SetReadDeadline(utils.NowSec().Add(dead))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error("SetDeadline: ", cSess.Username, err)
|
base.Error("SetDeadline: ", cSess.Username, cSess.IpAddr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pl := getPayload()
|
pl := getPayload()
|
||||||
n, err = conn.Read(pl.Data)
|
n, err = conn.Read(pl.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error("read hdata: ", cSess.Username, err)
|
base.Warn("read hdata: ", cSess.Username, cSess.IpAddr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,19 +56,21 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
|
|||||||
switch pl.Data[0] {
|
switch pl.Data[0] {
|
||||||
case 0x07: // KEEPALIVE
|
case 0x07: // KEEPALIVE
|
||||||
// do nothing
|
// do nothing
|
||||||
// base.Debug("recv keepalive", cSess.IpAddr)
|
base.Trace("recv LinkDtls Keepalive", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
case 0x05: // DISCONNECT
|
case 0x05: // DISCONNECT
|
||||||
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
||||||
base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr)
|
base.Info("DISCONNECT DTLS", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
return
|
return
|
||||||
case 0x03: // DPD-REQ
|
case 0x03: // DPD-REQ
|
||||||
// base.Debug("recv DPD-REQ", cSess.IpAddr)
|
base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n)
|
||||||
pl.PType = 0x04
|
pl.PType = 0x04
|
||||||
|
// 从零开始 可以直接赋值
|
||||||
|
pl.Data = pl.Data[:n]
|
||||||
if payloadOutDtls(cSess, dSess, pl) {
|
if payloadOutDtls(cSess, dSess, pl) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 0x04:
|
case 0x04:
|
||||||
// base.Debug("recv DPD-RESP", cSess.IpAddr)
|
base.Trace("recv LinkDtls DPD-RESP", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
case 0x08: // decompress
|
case 0x08: // decompress
|
||||||
if cSess.DtlsPickCmp == nil {
|
if cSess.DtlsPickCmp == nil {
|
||||||
continue
|
continue
|
||||||
@@ -93,6 +95,8 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
|
|||||||
if payloadIn(cSess, pl) {
|
if payloadIn(cSess, pl) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 只记录返回正确的数据时间
|
||||||
|
cSess.LastDataTime.Store(utils.NowSec().Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -147,11 +151,15 @@ func dtlsWrite(conn net.Conn, dSess *sessdata.DtlsSession, cSess *sessdata.ConnS
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 设置头类型
|
// 设置头类型
|
||||||
pl.Data = append(pl.Data[:0], pl.PType)
|
if pl.PType == 0x04 {
|
||||||
|
pl.Data[0] = pl.PType
|
||||||
|
} else {
|
||||||
|
pl.Data = append(pl.Data[:0], pl.PType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
n, err := conn.Write(pl.Data)
|
n, err := conn.Write(pl.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error("write err", cSess.Username, err)
|
base.Warn("write err", cSess.Username, cSess.IpAddr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@ func LinkHome(w http.ResponseWriter, r *http.Request) {
|
|||||||
// hu, _ := httputil.DumpRequest(r, true)
|
// hu, _ := httputil.DumpRequest(r, true)
|
||||||
// fmt.Println("DumpHome: ", string(hu))
|
// fmt.Println("DumpHome: ", string(hu))
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
|
w.Header().Del("X-Aggregate-Auth")
|
||||||
|
|
||||||
connection := strings.ToLower(r.Header.Get("Connection"))
|
connection := strings.ToLower(r.Header.Get("Connection"))
|
||||||
userAgent := strings.ToLower(r.UserAgent())
|
userAgent := strings.ToLower(r.UserAgent())
|
||||||
if connection == "close" && (strings.Contains(userAgent, "anyconnect") || strings.Contains(userAgent, "openconnect")) {
|
if connection == "close" && (strings.Contains(userAgent, "anyconnect") || strings.Contains(userAgent, "openconnect")) {
|
||||||
@@ -25,14 +27,22 @@ func LinkHome(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err := dbdata.SettingGet(index); err != nil {
|
if err := dbdata.SettingGet(index); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
if index.Homeindex == "" {
|
if index.Homecode > 0 {
|
||||||
index.Homeindex = "AnyLink 是一个企业级远程办公 SSL VPN 软件,可以支持多人同时在线使用。"
|
w.WriteHeader(index.Homecode)
|
||||||
|
} else {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if index.Homeindex == "" {
|
||||||
|
// index.Homeindex = "AnyLink 是一个企业级远程办公 SSL VPN 软件,可以支持多人同时在线使用。"
|
||||||
|
// }
|
||||||
fmt.Fprintln(w, index.Homeindex)
|
fmt.Fprintln(w, index.Homeindex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LinkOtpQr(w http.ResponseWriter, r *http.Request) {
|
func LinkOtpQr(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Cross-Origin-Resource-Policy", "cross-origin")
|
||||||
|
|
||||||
_ = r.ParseForm()
|
_ = r.ParseForm()
|
||||||
idS := r.FormValue("id")
|
idS := r.FormValue("id")
|
||||||
jwtToken := r.FormValue("jwt")
|
jwtToken := r.FormValue("jwt")
|
||||||
|
@@ -4,12 +4,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/bjdgyc/anylink/base"
|
"github.com/bjdgyc/anylink/base"
|
||||||
|
"github.com/bjdgyc/anylink/pkg/utils"
|
||||||
"github.com/bjdgyc/anylink/sessdata"
|
"github.com/bjdgyc/anylink/sessdata"
|
||||||
"github.com/coreos/go-iptables/iptables"
|
"github.com/coreos/go-iptables/iptables"
|
||||||
"github.com/songgao/water"
|
"github.com/songgao/water"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkTun() {
|
func checkTun() {
|
||||||
|
// 测试ip命令
|
||||||
|
base.CheckModOrLoad("tun")
|
||||||
|
|
||||||
// 测试tun
|
// 测试tun
|
||||||
cfg := water.Config{
|
cfg := water.Config{
|
||||||
DeviceType: water.TUN,
|
DeviceType: water.TUN,
|
||||||
@@ -21,16 +25,14 @@ func checkTun() {
|
|||||||
}
|
}
|
||||||
defer ifce.Close()
|
defer ifce.Close()
|
||||||
|
|
||||||
// 测试ip命令
|
|
||||||
base.CheckModOrLoad("tun")
|
|
||||||
|
|
||||||
cmdstr1 := fmt.Sprintf("ip link set dev %s up mtu %s multicast off", ifce.Name(), "1399")
|
cmdstr1 := fmt.Sprintf("ip link set dev %s up mtu %s multicast off", ifce.Name(), "1399")
|
||||||
err = execCmd([]string{cmdstr1})
|
err = execCmd([]string{cmdstr1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Fatal("testTun err: ", err)
|
base.Fatal("testTun err: ", err)
|
||||||
}
|
}
|
||||||
// 开启服务器转发
|
// 开启服务器转发
|
||||||
if err := execCmd([]string{"sysctl -w net.ipv4.ip_forward=1"}); err != nil {
|
err = execCmd([]string{"sysctl -w net.ipv4.ip_forward=1"})
|
||||||
|
if err != nil {
|
||||||
base.Fatal(err)
|
base.Fatal(err)
|
||||||
}
|
}
|
||||||
if base.Cfg.IptablesNat {
|
if base.Cfg.IptablesNat {
|
||||||
@@ -44,15 +46,29 @@ func checkTun() {
|
|||||||
// 修复 rockyos nat 不生效
|
// 修复 rockyos nat 不生效
|
||||||
base.CheckModOrLoad("iptable_filter")
|
base.CheckModOrLoad("iptable_filter")
|
||||||
base.CheckModOrLoad("iptable_nat")
|
base.CheckModOrLoad("iptable_nat")
|
||||||
|
// base.CheckModOrLoad("xt_comment")
|
||||||
|
|
||||||
natRule := []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-j", "MASQUERADE"}
|
// 添加注释
|
||||||
forwardRule := []string{"-j", "ACCEPT"}
|
natRule := []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-m", "comment",
|
||||||
if natExists, _ := ipt.Exists("nat", "POSTROUTING", natRule...); !natExists {
|
"--comment", "AnyLink", "-j", "MASQUERADE"}
|
||||||
ipt.Insert("nat", "POSTROUTING", 1, natRule...)
|
if base.InContainer {
|
||||||
|
natRule = []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-j", "MASQUERADE"}
|
||||||
}
|
}
|
||||||
if forwardExists, _ := ipt.Exists("filter", "FORWARD", forwardRule...); !forwardExists {
|
err = ipt.InsertUnique("nat", "POSTROUTING", 1, natRule...)
|
||||||
ipt.Insert("filter", "FORWARD", 1, forwardRule...)
|
if err != nil {
|
||||||
|
base.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加注释
|
||||||
|
forwardRule := []string{"-m", "comment", "--comment", "AnyLink", "-j", "ACCEPT"}
|
||||||
|
if base.InContainer {
|
||||||
|
forwardRule = []string{"-j", "ACCEPT"}
|
||||||
|
}
|
||||||
|
err = ipt.InsertUnique("filter", "FORWARD", 1, forwardRule...)
|
||||||
|
if err != nil {
|
||||||
|
base.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
base.Info(ipt.List("nat", "POSTROUTING"))
|
base.Info(ipt.List("nat", "POSTROUTING"))
|
||||||
base.Info(ipt.List("filter", "FORWARD"))
|
base.Info(ipt.List("filter", "FORWARD"))
|
||||||
}
|
}
|
||||||
@@ -73,12 +89,8 @@ func LinkTun(cSess *sessdata.ConnSession) error {
|
|||||||
cSess.SetIfName(ifce.Name())
|
cSess.SetIfName(ifce.Name())
|
||||||
|
|
||||||
// 通过 ip link show 查看 alias 信息
|
// 通过 ip link show 查看 alias 信息
|
||||||
|
alias := utils.ParseName(cSess.Group.Name + "." + cSess.Username)
|
||||||
cmdstr1 := fmt.Sprintf("ip link set dev %s up mtu %d multicast off", ifce.Name(), cSess.Mtu)
|
cmdstr1 := fmt.Sprintf("ip link set dev %s up mtu %d multicast off alias %s", ifce.Name(), cSess.Mtu, alias)
|
||||||
if !base.InContainer {
|
|
||||||
// 容器默认 iproute 不支持 alias
|
|
||||||
cmdstr1 += fmt.Sprintf(" alias %s.%s", cSess.Group.Name, cSess.Username)
|
|
||||||
}
|
|
||||||
cmdstr2 := fmt.Sprintf("ip addr add dev %s local %s peer %s/32",
|
cmdstr2 := fmt.Sprintf("ip addr add dev %s local %s peer %s/32",
|
||||||
ifce.Name(), base.Cfg.Ipv4Gateway, cSess.IpAddr)
|
ifce.Name(), base.Cfg.Ipv4Gateway, cSess.IpAddr)
|
||||||
err = execCmd([]string{cmdstr1, cmdstr2})
|
err = execCmd([]string{cmdstr1, cmdstr2})
|
||||||
|
@@ -43,13 +43,13 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
// 判断session-token的值
|
// 判断session-token的值
|
||||||
cookie, err := r.Cookie("webvpn")
|
cookie, err := r.Cookie("webvpn")
|
||||||
if err != nil || cookie.Value == "" {
|
if err != nil || cookie.Value == "" {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sess := sessdata.SToken2Sess(cookie.Value)
|
sess := sessdata.SToken2Sess(cookie.Value)
|
||||||
if sess == nil {
|
if sess == nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
cSess := sess.NewConn()
|
cSess := sess.NewConn()
|
||||||
if cSess == nil {
|
if cSess == nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +66,8 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
cstpBaseMtu := r.Header.Get("X-CSTP-Base-MTU")
|
cstpBaseMtu := r.Header.Get("X-CSTP-Base-MTU")
|
||||||
masterSecret := r.Header.Get("X-DTLS-Master-Secret")
|
masterSecret := r.Header.Get("X-DTLS-Master-Secret")
|
||||||
localIp := r.Header.Get("X-Cstp-Local-Address-Ip4")
|
localIp := r.Header.Get("X-Cstp-Local-Address-Ip4")
|
||||||
|
// 出口ip
|
||||||
|
exportIp4 := r.Header.Get("X-Cstp-Remote-Address-Ip4")
|
||||||
mobile := r.Header.Get("X-Cstp-License")
|
mobile := r.Header.Get("X-Cstp-License")
|
||||||
|
|
||||||
cSess.SetMtu(cstpMtu)
|
cSess.SetMtu(cstpMtu)
|
||||||
@@ -90,20 +92,12 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
dtlsPort = ss[1]
|
dtlsPort = ss[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Debug(cSess.IpAddr, cSess.MacHw, sess.Username, mobile)
|
base.Info(sess.Username, cSess.IpAddr, cSess.MacHw, cSess.Client, mobile)
|
||||||
|
|
||||||
// 检测密码套件
|
// 检测密码套件
|
||||||
dtlsCiphersuite := checkDtls12Ciphersuite(r.Header.Get("X-Dtls12-Ciphersuite"))
|
dtlsCiphersuite := checkDtls12Ciphersuite(r.Header.Get("X-Dtls12-Ciphersuite"))
|
||||||
base.Trace("dtlsCiphersuite", dtlsCiphersuite)
|
base.Trace("dtlsCiphersuite", dtlsCiphersuite)
|
||||||
|
|
||||||
// 压缩
|
|
||||||
if cmpName, ok := cSess.SetPickCmp("cstp", r.Header.Get("X-Cstp-Accept-Encoding")); ok {
|
|
||||||
HttpSetHeader(w, "X-CSTP-Content-Encoding", cmpName)
|
|
||||||
}
|
|
||||||
if cmpName, ok := cSess.SetPickCmp("dtls", r.Header.Get("X-Dtls-Accept-Encoding")); ok {
|
|
||||||
HttpSetHeader(w, "X-DTLS-Content-Encoding", cmpName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回客户端数据
|
// 返回客户端数据
|
||||||
HttpSetHeader(w, "Server", fmt.Sprintf("%s %s", base.APP_NAME, base.APP_VER))
|
HttpSetHeader(w, "Server", fmt.Sprintf("%s %s", base.APP_NAME, base.APP_VER))
|
||||||
HttpSetHeader(w, "X-CSTP-Version", "1")
|
HttpSetHeader(w, "X-CSTP-Version", "1")
|
||||||
@@ -113,11 +107,19 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
HttpSetHeader(w, "X-CSTP-Netmask", sessdata.IpPool.Ipv4Mask.String()) // 子网掩码
|
HttpSetHeader(w, "X-CSTP-Netmask", sessdata.IpPool.Ipv4Mask.String()) // 子网掩码
|
||||||
HttpSetHeader(w, "X-CSTP-Hostname", hn) // 机器名称
|
HttpSetHeader(w, "X-CSTP-Hostname", hn) // 机器名称
|
||||||
HttpSetHeader(w, "X-CSTP-Base-MTU", cstpBaseMtu)
|
HttpSetHeader(w, "X-CSTP-Base-MTU", cstpBaseMtu)
|
||||||
// 要发布的默认域
|
// 客户端dns的默认搜索域
|
||||||
if base.Cfg.DefaultDomain != "" {
|
if base.Cfg.DefaultDomain != "" {
|
||||||
HttpSetHeader(w, "X-CSTP-Default-Domain", base.Cfg.DefaultDomain)
|
HttpSetHeader(w, "X-CSTP-Default-Domain", base.Cfg.DefaultDomain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 压缩
|
||||||
|
if cmpName, ok := cSess.SetPickCmp("cstp", r.Header.Get("X-Cstp-Accept-Encoding")); ok {
|
||||||
|
HttpSetHeader(w, "X-CSTP-Content-Encoding", cmpName)
|
||||||
|
}
|
||||||
|
if cmpName, ok := cSess.SetPickCmp("dtls", r.Header.Get("X-Dtls-Accept-Encoding")); ok {
|
||||||
|
HttpSetHeader(w, "X-DTLS-Content-Encoding", cmpName)
|
||||||
|
}
|
||||||
|
|
||||||
// 设置用户策略
|
// 设置用户策略
|
||||||
SetUserPolicy(cSess.Username, cSess.Group)
|
SetUserPolicy(cSess.Username, cSess.Group)
|
||||||
|
|
||||||
@@ -131,7 +133,7 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
// 允许的路由
|
// 允许的路由
|
||||||
for _, v := range cSess.Group.RouteInclude {
|
for _, v := range cSess.Group.RouteInclude {
|
||||||
if v.Val == dbdata.All {
|
if strings.ToLower(v.Val) == dbdata.All {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
HttpAddHeader(w, "X-CSTP-Split-Include", v.IpMask)
|
HttpAddHeader(w, "X-CSTP-Split-Include", v.IpMask)
|
||||||
@@ -140,6 +142,10 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
for _, v := range cSess.Group.RouteExclude {
|
for _, v := range cSess.Group.RouteExclude {
|
||||||
HttpAddHeader(w, "X-CSTP-Split-Exclude", v.IpMask)
|
HttpAddHeader(w, "X-CSTP-Split-Exclude", v.IpMask)
|
||||||
}
|
}
|
||||||
|
// 排除出口ip路由(出口ip不加密传输)
|
||||||
|
if base.Cfg.ExcludeExportIp && exportIp4 != "" {
|
||||||
|
HttpAddHeader(w, "X-CSTP-Split-Exclude", exportIp4+"/255.255.255.255")
|
||||||
|
}
|
||||||
|
|
||||||
HttpSetHeader(w, "X-CSTP-Lease-Duration", "1209600") // ip地址租期
|
HttpSetHeader(w, "X-CSTP-Lease-Duration", "1209600") // ip地址租期
|
||||||
HttpSetHeader(w, "X-CSTP-Session-Timeout", "none")
|
HttpSetHeader(w, "X-CSTP-Session-Timeout", "none")
|
||||||
@@ -184,10 +190,9 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
hClone := w.Header().Clone()
|
hClone := w.Header().Clone()
|
||||||
headers := make([]byte, 0)
|
buf := &bytes.Buffer{}
|
||||||
buf := bytes.NewBuffer(headers)
|
|
||||||
_ = hClone.Write(buf)
|
_ = hClone.Write(buf)
|
||||||
base.Debug(buf.String())
|
base.Debug("LinkTunnel Response Header:", buf.String())
|
||||||
|
|
||||||
hj := w.(http.Hijacker)
|
hj := w.(http.Hijacker)
|
||||||
conn, bufRW, err := hj.Hijack()
|
conn, bufRW, err := hj.Hijack()
|
||||||
|
@@ -28,12 +28,13 @@ func (v *Vtap) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkMacvtap() {
|
func checkMacvtap() {
|
||||||
|
// 加载 macvtap
|
||||||
|
base.CheckModOrLoad("macvtap")
|
||||||
|
|
||||||
_setGateway()
|
_setGateway()
|
||||||
_checkTapIp(base.Cfg.Ipv4Master)
|
_checkTapIp(base.Cfg.Ipv4Master)
|
||||||
|
|
||||||
ifName := "anylinkMacvtap"
|
ifName := "anylinkMacvtap"
|
||||||
// 加载 macvtap
|
|
||||||
base.CheckModOrLoad("macvtap")
|
|
||||||
|
|
||||||
// 开启主网卡混杂模式
|
// 开启主网卡混杂模式
|
||||||
cmdstr1 := fmt.Sprintf("ip link set dev %s promisc on", base.Cfg.Ipv4Master)
|
cmdstr1 := fmt.Sprintf("ip link set dev %s promisc on", base.Cfg.Ipv4Master)
|
||||||
@@ -55,11 +56,9 @@ func LinkMacvtap(cSess *sessdata.ConnSession) error {
|
|||||||
cSess.SetIfName(ifName)
|
cSess.SetIfName(ifName)
|
||||||
|
|
||||||
cmdstr1 := fmt.Sprintf("ip link add link %s name %s type macvtap mode bridge", base.Cfg.Ipv4Master, ifName)
|
cmdstr1 := fmt.Sprintf("ip link add link %s name %s type macvtap mode bridge", base.Cfg.Ipv4Master, ifName)
|
||||||
cmdstr2 := fmt.Sprintf("ip link set dev %s up mtu %d address %s", ifName, cSess.Mtu, cSess.MacHw)
|
alias := utils.ParseName(cSess.Group.Name + "." + cSess.Username)
|
||||||
if !base.InContainer {
|
cmdstr2 := fmt.Sprintf("ip link set dev %s up mtu %d address %s alias %s", ifName, cSess.Mtu, cSess.MacHw, alias)
|
||||||
// 容器默认 iproute 不支持 alias
|
|
||||||
cmdstr2 += fmt.Sprintf(" alias %s.%s", cSess.Group.Name, cSess.Username)
|
|
||||||
}
|
|
||||||
err := execCmd([]string{cmdstr1, cmdstr2})
|
err := execCmd([]string{cmdstr1, cmdstr2})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Error(err)
|
base.Error(err)
|
||||||
|
@@ -135,6 +135,7 @@ func logAudit(userName string, pl *sessdata.Payload) {
|
|||||||
ipSrc := waterutil.IPv4Source(pl.Data)
|
ipSrc := waterutil.IPv4Source(pl.Data)
|
||||||
ipDst := waterutil.IPv4Destination(pl.Data)
|
ipDst := waterutil.IPv4Destination(pl.Data)
|
||||||
b := getByte51()
|
b := getByte51()
|
||||||
|
// key格式 16字节源IP地址 + 16字节目的IP地址 + 2字节目的端口 + 1字节协议类型 + 16字节域名MD5
|
||||||
key := *b
|
key := *b
|
||||||
copy(key[:16], ipSrc)
|
copy(key[:16], ipSrc)
|
||||||
copy(key[16:32], ipDst)
|
copy(key[16:32], ipDst)
|
||||||
|
@@ -4,9 +4,9 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ func startTls() {
|
|||||||
MinVersion: tls.VersionTLS12,
|
MinVersion: tls.VersionTLS12,
|
||||||
CipherSuites: selectedCipherSuites,
|
CipherSuites: selectedCipherSuites,
|
||||||
GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) {
|
||||||
base.Trace("GetCertificate", chi.ServerName)
|
base.Trace("GetCertificate ServerName", chi.ServerName)
|
||||||
return dbdata.GetCertificateBySNI(chi.ServerName)
|
return dbdata.GetCertificateBySNI(chi.ServerName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -59,14 +59,14 @@ func startTls() {
|
|||||||
Addr: addr,
|
Addr: addr,
|
||||||
Handler: initRoute(),
|
Handler: initRoute(),
|
||||||
TLSConfig: tlsConfig,
|
TLSConfig: tlsConfig,
|
||||||
ErrorLog: base.GetBaseLog(),
|
ErrorLog: base.GetServerLog(),
|
||||||
ReadTimeout: 60 * time.Second,
|
ReadTimeout: 100 * time.Second,
|
||||||
WriteTimeout: 60 * time.Second,
|
WriteTimeout: 100 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
ln, err = net.Listen("tcp", addr)
|
ln, err = net.Listen("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
base.Fatal(err)
|
||||||
}
|
}
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ func initRoute() http.Handler {
|
|||||||
r.HandleFunc("/", LinkAuth).Methods(http.MethodPost)
|
r.HandleFunc("/", LinkAuth).Methods(http.MethodPost)
|
||||||
r.HandleFunc("/CSCOSSLC/tunnel", LinkTunnel).Methods(http.MethodConnect)
|
r.HandleFunc("/CSCOSSLC/tunnel", LinkTunnel).Methods(http.MethodConnect)
|
||||||
r.HandleFunc("/otp_qr", LinkOtpQr).Methods(http.MethodGet)
|
r.HandleFunc("/otp_qr", LinkOtpQr).Methods(http.MethodGet)
|
||||||
r.HandleFunc("/profile.xml", func(w http.ResponseWriter, r *http.Request) {
|
r.HandleFunc(fmt.Sprintf("/profile_%s.xml", base.Cfg.ProfileName), func(w http.ResponseWriter, r *http.Request) {
|
||||||
b, _ := os.ReadFile(base.Cfg.Profile)
|
b, _ := os.ReadFile(base.Cfg.Profile)
|
||||||
w.Write(b)
|
w.Write(b)
|
||||||
}).Methods(http.MethodGet)
|
}).Methods(http.MethodGet)
|
||||||
@@ -117,8 +117,10 @@ func initRoute() http.Handler {
|
|||||||
|
|
||||||
func notFound(w http.ResponseWriter, r *http.Request) {
|
func notFound(w http.ResponseWriter, r *http.Request) {
|
||||||
// fmt.Println(r.RemoteAddr)
|
// fmt.Println(r.RemoteAddr)
|
||||||
// hu, _ := httputil.DumpRequest(r, true)
|
if base.GetLogLevel() == base.LogLevelTrace {
|
||||||
// fmt.Println("NotFound: ", string(hu))
|
hd, _ := httputil.DumpRequest(r, true)
|
||||||
|
base.Trace("NotFound: ", r.RemoteAddr, string(hd))
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
fmt.Fprintln(w, "404 page not found")
|
fmt.Fprintln(w, "404 page not found")
|
||||||
|
@@ -17,6 +17,12 @@ func Start() {
|
|||||||
sessdata.Start()
|
sessdata.Start()
|
||||||
cron.Start()
|
cron.Start()
|
||||||
|
|
||||||
|
// 开启服务器转发
|
||||||
|
err := execCmd([]string{"sysctl -w net.ipv4.ip_forward=1"})
|
||||||
|
if err != nil {
|
||||||
|
base.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
switch base.Cfg.LinkMode {
|
switch base.Cfg.LinkMode {
|
||||||
case base.LinkModeTUN:
|
case base.LinkModeTUN:
|
||||||
checkTun()
|
checkTun()
|
||||||
|
@@ -20,14 +20,21 @@ import (
|
|||||||
var uiData embed.FS
|
var uiData embed.FS
|
||||||
|
|
||||||
// 程序版本
|
// 程序版本
|
||||||
var CommitId string
|
var (
|
||||||
|
appVer string
|
||||||
|
commitId string
|
||||||
|
buildDate string
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
base.CommitId = CommitId
|
|
||||||
admin.UiData = uiData
|
admin.UiData = uiData
|
||||||
|
base.APP_VER = appVer
|
||||||
|
base.CommitId = commitId
|
||||||
|
base.BuildDate = buildDate
|
||||||
|
|
||||||
base.Start()
|
base.Start()
|
||||||
handler.Start()
|
handler.Start()
|
||||||
|
|
||||||
signalWatch()
|
signalWatch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +42,7 @@ func signalWatch() {
|
|||||||
base.Info("Server pid: ", os.Getpid())
|
base.Info("Server pid: ", os.Getpid())
|
||||||
|
|
||||||
sigs := make(chan os.Signal, 1)
|
sigs := make(chan os.Signal, 1)
|
||||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGALRM)
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGALRM, syscall.SIGUSR2)
|
||||||
for {
|
for {
|
||||||
sig := <-sigs
|
sig := <-sigs
|
||||||
base.Info("Get signal:", sig)
|
base.Info("Get signal:", sig)
|
||||||
|
@@ -3,6 +3,7 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -91,3 +92,11 @@ func RandomRunes(length int) string {
|
|||||||
|
|
||||||
return string(bytes)
|
return string(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ParseName(name string) string {
|
||||||
|
name = strings.ReplaceAll(name, " ", "-")
|
||||||
|
name = strings.ReplaceAll(name, "'", "-")
|
||||||
|
name = strings.ReplaceAll(name, "\"", "-")
|
||||||
|
name = strings.ReplaceAll(name, ";", "-")
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
@@ -89,10 +89,13 @@ func initIpPool() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// AcquireIp 获取动态ip
|
// AcquireIp 获取动态ip
|
||||||
func AcquireIp(username, macAddr string, uniqueMac bool) net.IP {
|
func AcquireIp(username, macAddr string, uniqueMac bool) (newIp net.IP) {
|
||||||
base.Trace("AcquireIp:", username, macAddr, uniqueMac)
|
base.Trace("AcquireIp start:", username, macAddr, uniqueMac)
|
||||||
ipPoolMux.Lock()
|
ipPoolMux.Lock()
|
||||||
defer ipPoolMux.Unlock()
|
defer func() {
|
||||||
|
ipPoolMux.Unlock()
|
||||||
|
base.Trace("AcquireIp end:", username, macAddr, uniqueMac, newIp)
|
||||||
|
}()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bjdgyc/anylink/pkg/utils"
|
"github.com/bjdgyc/anylink/pkg/utils"
|
||||||
@@ -42,33 +43,74 @@ func (o Onlines) Swap(i, j int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func OnlineSess() []Online {
|
func OnlineSess() []Online {
|
||||||
|
return GetOnlineSess("", "", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: GetOnlineSess
|
||||||
|
* @param search_cate 分类:用户名、登录组、MAC地址、IP地址、远端地址
|
||||||
|
* @param search_text 关键字,模糊搜索
|
||||||
|
* @param show_sleeper 是否显示休眠用户
|
||||||
|
* @return []Online
|
||||||
|
*/
|
||||||
|
func GetOnlineSess(search_cate string, search_text string, show_sleeper bool) []Online {
|
||||||
var datas Onlines
|
var datas Onlines
|
||||||
|
if strings.TrimSpace(search_text) == "" {
|
||||||
|
search_cate = ""
|
||||||
|
}
|
||||||
sessMux.Lock()
|
sessMux.Lock()
|
||||||
|
defer sessMux.Unlock()
|
||||||
for _, v := range sessions {
|
for _, v := range sessions {
|
||||||
v.mux.Lock()
|
v.mux.Lock()
|
||||||
if v.IsActive {
|
cSess := v.CSess
|
||||||
|
if cSess == nil {
|
||||||
|
cSess = &ConnSession{}
|
||||||
|
}
|
||||||
|
// 选择需要比较的字符串
|
||||||
|
var compareText string
|
||||||
|
switch search_cate {
|
||||||
|
case "username":
|
||||||
|
compareText = v.Username
|
||||||
|
case "group":
|
||||||
|
compareText = v.Group
|
||||||
|
case "mac_addr":
|
||||||
|
compareText = v.MacAddr
|
||||||
|
case "ip":
|
||||||
|
if cSess != nil {
|
||||||
|
compareText = cSess.IpAddr.String()
|
||||||
|
}
|
||||||
|
case "remote_addr":
|
||||||
|
if cSess != nil {
|
||||||
|
compareText = cSess.RemoteAddr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if search_cate != "" && !strings.Contains(compareText, search_text) {
|
||||||
|
v.mux.Unlock()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if show_sleeper || v.IsActive {
|
||||||
val := Online{
|
val := Online{
|
||||||
Token: v.Token,
|
Token: v.Token,
|
||||||
Ip: v.CSess.IpAddr,
|
Ip: cSess.IpAddr,
|
||||||
Username: v.Username,
|
Username: v.Username,
|
||||||
Group: v.Group,
|
Group: v.Group,
|
||||||
MacAddr: v.MacAddr,
|
MacAddr: v.MacAddr,
|
||||||
UniqueMac: v.UniqueMac,
|
UniqueMac: v.UniqueMac,
|
||||||
RemoteAddr: v.CSess.RemoteAddr,
|
RemoteAddr: cSess.RemoteAddr,
|
||||||
TunName: v.CSess.IfName,
|
TunName: cSess.IfName,
|
||||||
Mtu: v.CSess.Mtu,
|
Mtu: cSess.Mtu,
|
||||||
Client: v.CSess.Client,
|
Client: cSess.Client,
|
||||||
BandwidthUp: utils.HumanByte(v.CSess.BandwidthUpPeriod.Load()) + "/s",
|
BandwidthUp: utils.HumanByte(cSess.BandwidthUpPeriod.Load()) + "/s",
|
||||||
BandwidthDown: utils.HumanByte(v.CSess.BandwidthDownPeriod.Load()) + "/s",
|
BandwidthDown: utils.HumanByte(cSess.BandwidthDownPeriod.Load()) + "/s",
|
||||||
BandwidthUpAll: utils.HumanByte(v.CSess.BandwidthUpAll.Load()),
|
BandwidthUpAll: utils.HumanByte(cSess.BandwidthUpAll.Load()),
|
||||||
BandwidthDownAll: utils.HumanByte(v.CSess.BandwidthDownAll.Load()),
|
BandwidthDownAll: utils.HumanByte(cSess.BandwidthDownAll.Load()),
|
||||||
LastLogin: v.LastLogin,
|
LastLogin: v.LastLogin,
|
||||||
}
|
}
|
||||||
datas = append(datas, val)
|
datas = append(datas, val)
|
||||||
}
|
}
|
||||||
v.mux.Unlock()
|
v.mux.Unlock()
|
||||||
}
|
}
|
||||||
sessMux.Unlock()
|
|
||||||
sort.Sort(&datas)
|
sort.Sort(&datas)
|
||||||
return datas
|
return datas
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/bjdgyc/anylink/base"
|
"github.com/bjdgyc/anylink/base"
|
||||||
"github.com/bjdgyc/anylink/dbdata"
|
"github.com/bjdgyc/anylink/dbdata"
|
||||||
mapset "github.com/deckarep/golang-set"
|
mapset "github.com/deckarep/golang-set"
|
||||||
atomic2 "go.uber.org/atomic"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -41,14 +40,15 @@ type ConnSession struct {
|
|||||||
CstpDpd int
|
CstpDpd int
|
||||||
Group *dbdata.Group
|
Group *dbdata.Group
|
||||||
Limit *LimitRater
|
Limit *LimitRater
|
||||||
BandwidthUp atomic2.Uint32 // 使用上行带宽 Byte
|
BandwidthUp atomic.Uint32 // 使用上行带宽 Byte
|
||||||
BandwidthDown atomic2.Uint32 // 使用下行带宽 Byte
|
BandwidthDown atomic.Uint32 // 使用下行带宽 Byte
|
||||||
BandwidthUpPeriod atomic2.Uint32 // 前一周期的总量
|
BandwidthUpPeriod atomic.Uint32 // 前一周期的总量
|
||||||
BandwidthDownPeriod atomic2.Uint32
|
BandwidthDownPeriod atomic.Uint32
|
||||||
BandwidthUpAll atomic2.Uint64 // 使用上行带宽总量
|
BandwidthUpAll atomic.Uint64 // 使用上行带宽总量
|
||||||
BandwidthDownAll atomic2.Uint64 // 使用下行带宽总量
|
BandwidthDownAll atomic.Uint64 // 使用下行带宽总量
|
||||||
closeOnce sync.Once
|
closeOnce sync.Once
|
||||||
CloseChan chan struct{}
|
CloseChan chan struct{}
|
||||||
|
LastDataTime atomic.Int64 // 最后数据传输时间
|
||||||
PayloadIn chan *Payload
|
PayloadIn chan *Payload
|
||||||
PayloadOutCstp chan *Payload // Cstp的数据
|
PayloadOutCstp chan *Payload // Cstp的数据
|
||||||
PayloadOutDtls chan *Payload // Dtls的数据
|
PayloadOutDtls chan *Payload // Dtls的数据
|
||||||
@@ -219,6 +219,7 @@ func (s *Session) NewConn() *ConnSession {
|
|||||||
PayloadOutDtls: make(chan *Payload, 64),
|
PayloadOutDtls: make(chan *Payload, 64),
|
||||||
dSess: &atomic.Value{},
|
dSess: &atomic.Value{},
|
||||||
}
|
}
|
||||||
|
cSess.LastDataTime.Store(time.Now().Unix())
|
||||||
|
|
||||||
dSess := &DtlsSession{
|
dSess := &DtlsSession{
|
||||||
isActive: -1,
|
isActive: -1,
|
||||||
@@ -462,7 +463,7 @@ func CloseSess(token string, code ...uint8) {
|
|||||||
sess.CSess.Close()
|
sess.CSess.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
AddUserActLogBySess(sess)
|
AddUserActLogBySess(sess, code...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CloseCSess(token string) {
|
func CloseCSess(token string) {
|
||||||
@@ -499,7 +500,7 @@ func AddUserActLog(cs *ConnSession) {
|
|||||||
dbdata.UserActLogIns.Add(ua, cs.UserAgent)
|
dbdata.UserActLogIns.Add(ua, cs.UserAgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddUserActLogBySess(sess *Session) {
|
func AddUserActLogBySess(sess *Session, code ...uint8) {
|
||||||
ua := dbdata.UserActLog{
|
ua := dbdata.UserActLog{
|
||||||
Username: sess.Username,
|
Username: sess.Username,
|
||||||
GroupName: sess.Group,
|
GroupName: sess.Group,
|
||||||
@@ -510,5 +511,8 @@ func AddUserActLogBySess(sess *Session) {
|
|||||||
Status: dbdata.UserLogout,
|
Status: dbdata.UserLogout,
|
||||||
}
|
}
|
||||||
ua.Info = dbdata.UserActLogIns.GetInfoOpsById(dbdata.UserLogoutBanner)
|
ua.Info = dbdata.UserActLogIns.GetInfoOpsById(dbdata.UserLogoutBanner)
|
||||||
|
if len(code) > 0 {
|
||||||
|
ua.Info = dbdata.UserActLogIns.GetInfoOpsById(code[0])
|
||||||
|
}
|
||||||
dbdata.UserActLogIns.Add(ua, sess.UserAgent)
|
dbdata.UserActLogIns.Add(ua, sess.UserAgent)
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ func TestConnSession(t *testing.T) {
|
|||||||
sess.MacAddr = "00:15:5d:50:14:43"
|
sess.MacAddr = "00:15:5d:50:14:43"
|
||||||
|
|
||||||
cSess := sess.NewConn()
|
cSess := sess.NewConn()
|
||||||
base.Info("cSess", cSess)
|
// base.Info("cSess", cSess)
|
||||||
|
|
||||||
err := cSess.RateLimit(100, true)
|
err := cSess.RateLimit(100, true)
|
||||||
ast.Nil(err)
|
ast.Nil(err)
|
||||||
@@ -60,4 +60,7 @@ func TestConnSession(t *testing.T) {
|
|||||||
ast.Equal(cmpName, "")
|
ast.Equal(cmpName, "")
|
||||||
|
|
||||||
cSess.Close()
|
cSess.Close()
|
||||||
|
|
||||||
|
// 等待日志执行完成
|
||||||
|
time.Sleep(time.Second * 10)
|
||||||
}
|
}
|
||||||
|
1
version_info
Normal file
1
version_info
Normal file
@@ -0,0 +1 @@
|
|||||||
|
version_info
|
@@ -18,6 +18,14 @@
|
|||||||
<!--子组件上报route信息-->
|
<!--子组件上报route信息-->
|
||||||
<router-view :route_path.sync="route_path" :route_name.sync="route_name"></router-view>
|
<router-view :route_path.sync="route_path" :route_name.sync="route_name"></router-view>
|
||||||
</el-main>
|
</el-main>
|
||||||
|
<el-footer>
|
||||||
|
<div>
|
||||||
|
<el-button size="mini" @click="goUrl('https://gitee.com/bjdgyc/anylink')">
|
||||||
|
Powered by AnyLink
|
||||||
|
</el-button>
|
||||||
|
企业级远程办公系统 AGPL-3.0 ⓒ 2020-present
|
||||||
|
</div>
|
||||||
|
</el-footer>
|
||||||
</el-container>
|
</el-container>
|
||||||
</el-container>
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
@@ -36,6 +44,11 @@ export default {
|
|||||||
route_name: ['首页'],
|
route_name: ['首页'],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
goUrl(url) {
|
||||||
|
window.open(url, "_blank")
|
||||||
|
},
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
route_path: function (val) {
|
route_path: function (val) {
|
||||||
// var w = document.getElementById('layout-menu').clientWidth;
|
// var w = document.getElementById('layout-menu').clientWidth;
|
||||||
@@ -60,4 +73,16 @@ export default {
|
|||||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 12px;
|
||||||
|
margin: 0 12px;
|
||||||
|
color: rgb(134, 144, 156);
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -197,10 +197,14 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排除本地网络" prop="allow_lan">
|
<el-form-item label="排除本地网络" prop="allow_lan">
|
||||||
<el-switch
|
<!-- active-text="开启后 用户本地所在网段将不通过anylink加密传输" -->
|
||||||
v-model="ruleForm.allow_lan"
|
<el-switch v-model="ruleForm.allow_lan"></el-switch>
|
||||||
active-text="开启后 用户本地所在网段将不通过anylink加密传输">
|
<div class="msg-info">
|
||||||
</el-switch>
|
注:本地网络 指的是:
|
||||||
|
运行 anyconnect 客户端的PC 所在的的网络,既本地路由网段。
|
||||||
|
开启后,PC本地路由网段的数据就不会走隧道链路转发数据了。
|
||||||
|
同时 anyconnect 客户端需要勾选本地网络(Local Lan)的开关,功能才能生效。
|
||||||
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="客户端DNS" prop="client_dns">
|
<el-form-item label="客户端DNS" prop="client_dns">
|
||||||
@@ -377,7 +381,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排除域名" prop="ds_exclude_domains">
|
<el-form-item label="排除域名" prop="ds_exclude_domains">
|
||||||
<el-input type="textarea" :rows="5" v-model="ruleForm.ds_exclude_domains" placeholder="输入域名用,号分隔,默认匹配所有子域名, 如baidu.com,163.com"></el-input>
|
<el-input type="textarea" :rows="5" v-model="ruleForm.ds_exclude_domains" placeholder="输入域名用,号分隔,默认匹配所有子域名, 如baidu.com,163.com"></el-input>
|
||||||
<div class="msg-info">注:域名拆分隧道,仅支持AnyConnect的桌面客户端,不支持移动端.</div>
|
<div class="msg-info">注:域名拆分隧道,仅支持AnyConnect的windows和MacOS桌面客户端,不支持移动端.</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||||
<el-tab-pane label="邮件配置" name="dataSmtp">
|
<el-tab-pane label="邮件配置" name="dataSmtp">
|
||||||
<el-form
|
<el-form
|
||||||
:model="dataSmtp"
|
:model="dataSmtp"
|
||||||
ref="dataSmtp"
|
ref="dataSmtp"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
label-width="100px"
|
label-width="100px"
|
||||||
class="tab-one"
|
class="tab-one"
|
||||||
>
|
>
|
||||||
<el-form-item label="服务器地址" prop="host">
|
<el-form-item label="服务器地址" prop="host">
|
||||||
<el-input v-model="dataSmtp.host"></el-input>
|
<el-input v-model="dataSmtp.host"></el-input>
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密码" prop="password">
|
<el-form-item label="密码" prop="password">
|
||||||
<el-input
|
<el-input
|
||||||
type="password"
|
type="password"
|
||||||
v-model="dataSmtp.password"
|
v-model="dataSmtp.password"
|
||||||
placeholder="密码为空则不修改"
|
placeholder="密码为空则不修改"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="加密类型" prop="encryption">
|
<el-form-item label="加密类型" prop="encryption">
|
||||||
@@ -37,7 +37,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('dataSmtp')"
|
<el-button type="primary" @click="submitForm('dataSmtp')"
|
||||||
>保存</el-button
|
>保存
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
<el-button @click="resetForm('dataSmtp')">重置</el-button>
|
<el-button @click="resetForm('dataSmtp')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -46,19 +47,19 @@
|
|||||||
|
|
||||||
<el-tab-pane label="审计日志" name="dataAuditLog">
|
<el-tab-pane label="审计日志" name="dataAuditLog">
|
||||||
<el-form
|
<el-form
|
||||||
:model="dataAuditLog"
|
:model="dataAuditLog"
|
||||||
ref="dataAuditLog"
|
ref="dataAuditLog"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
label-width="100px"
|
label-width="100px"
|
||||||
class="tab-one"
|
class="tab-one"
|
||||||
>
|
>
|
||||||
<el-form-item label="审计去重间隔" prop="audit_interval">
|
<el-form-item label="审计去重间隔" prop="audit_interval">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="dataAuditLog.audit_interval"
|
v-model="dataAuditLog.audit_interval"
|
||||||
:min="-1"
|
:min="-1"
|
||||||
size="small"
|
size="small"
|
||||||
label="秒"
|
label="秒"
|
||||||
:disabled="true"
|
:disabled="true"
|
||||||
></el-input-number>
|
></el-input-number>
|
||||||
秒
|
秒
|
||||||
<p class="input_tip">
|
<p class="input_tip">
|
||||||
@@ -68,11 +69,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="存储时长" prop="life_day">
|
<el-form-item label="存储时长" prop="life_day">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="dataAuditLog.life_day"
|
v-model="dataAuditLog.life_day"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="365"
|
:max="365"
|
||||||
size="small"
|
size="small"
|
||||||
label="天数"
|
label="天数"
|
||||||
></el-input-number>
|
></el-input-number>
|
||||||
天
|
天
|
||||||
<p class="input_tip">
|
<p class="input_tip">
|
||||||
@@ -82,22 +83,23 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="清理时间" prop="clear_time">
|
<el-form-item label="清理时间" prop="clear_time">
|
||||||
<el-time-select
|
<el-time-select
|
||||||
v-model="dataAuditLog.clear_time"
|
v-model="dataAuditLog.clear_time"
|
||||||
:picker-options="{
|
:picker-options="{
|
||||||
start: '00:00',
|
start: '00:00',
|
||||||
step: '01:00',
|
step: '01:00',
|
||||||
end: '23:00',
|
end: '23:00',
|
||||||
}"
|
}"
|
||||||
editable="false,"
|
:editable="false"
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
style="width: 130px"
|
style="width: 130px"
|
||||||
>
|
>
|
||||||
</el-time-select>
|
</el-time-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('dataAuditLog')"
|
<el-button type="primary" @click="submitForm('dataAuditLog')"
|
||||||
>保存</el-button
|
>保存
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
<el-button @click="resetForm('dataAuditLog')">重置</el-button>
|
<el-button @click="resetForm('dataAuditLog')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -105,33 +107,34 @@
|
|||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="证书设置" name="datacertManage">
|
<el-tab-pane label="证书设置" name="datacertManage">
|
||||||
<el-tabs
|
<el-tabs
|
||||||
tab-position="left"
|
tab-position="left"
|
||||||
v-model="datacertManage"
|
v-model="datacertManage"
|
||||||
@tab-click="handleClick"
|
@tab-click="handleClick"
|
||||||
>
|
>
|
||||||
<el-tab-pane label="自定义证书" name="customCert">
|
<el-tab-pane label="自定义证书" name="customCert">
|
||||||
<el-form
|
<el-form
|
||||||
ref="customCert"
|
ref="customCert"
|
||||||
:model="customCert"
|
:model="customCert"
|
||||||
label-width="100px"
|
label-width="100px"
|
||||||
size="small"
|
size="small"
|
||||||
class="tab-one"
|
class="tab-one"
|
||||||
>
|
>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-upload
|
<el-upload
|
||||||
class="uploadCert"
|
class="uploadCert"
|
||||||
:before-upload="beforeCertUpload"
|
:before-upload="beforeCertUpload"
|
||||||
:action="certUpload"
|
:action="certUpload"
|
||||||
:limit="1"
|
:limit="1"
|
||||||
>
|
>
|
||||||
<el-button size="mini" icon="el-icon-plus" slot="trigger"
|
<el-button size="mini" icon="el-icon-plus" slot="trigger"
|
||||||
>证书文件</el-button
|
>证书文件
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
class="item"
|
class="item"
|
||||||
effect="dark"
|
effect="dark"
|
||||||
content="请上传 .pem 格式的 cert 文件"
|
content="请上传 .pem 格式的 cert 文件"
|
||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
<i class="el-icon-info"></i>
|
<i class="el-icon-info"></i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@@ -139,19 +142,20 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-upload
|
<el-upload
|
||||||
class="uploadCert"
|
class="uploadCert"
|
||||||
:before-upload="beforeKeyUpload"
|
:before-upload="beforeKeyUpload"
|
||||||
:action="certUpload"
|
:action="certUpload"
|
||||||
:limit="1"
|
:limit="1"
|
||||||
>
|
>
|
||||||
<el-button size="mini" icon="el-icon-plus" slot="trigger"
|
<el-button size="mini" icon="el-icon-plus" slot="trigger"
|
||||||
>私钥文件</el-button
|
>私钥文件
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
class="item"
|
class="item"
|
||||||
effect="dark"
|
effect="dark"
|
||||||
content="请上传 .pem 格式的 key 文件"
|
content="请上传 .pem 格式的 key 文件"
|
||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
<i class="el-icon-info"></i>
|
<i class="el-icon-info"></i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@@ -159,23 +163,24 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button
|
<el-button
|
||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-upload"
|
icon="el-icon-upload"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="submitForm('customCert')"
|
@click="submitForm('customCert')"
|
||||||
>上传</el-button
|
>上传
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="Let's Encrypt证书" name="letsCert">
|
<el-tab-pane label="Let's Encrypt证书" name="letsCert">
|
||||||
<el-form
|
<el-form
|
||||||
:model="letsCert"
|
:model="letsCert"
|
||||||
ref="letsCert"
|
ref="letsCert"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
label-width="120px"
|
label-width="120px"
|
||||||
size="small"
|
size="small"
|
||||||
class="tab-one"
|
class="tab-one"
|
||||||
>
|
>
|
||||||
<el-form-item label="域名" prop="domain">
|
<el-form-item label="域名" prop="domain">
|
||||||
<el-input v-model="letsCert.domain"></el-input>
|
<el-input v-model="letsCert.domain"></el-input>
|
||||||
@@ -191,30 +196,31 @@
|
|||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-for="component in dnsProvider[letsCert.name]"
|
v-for="component in dnsProvider[letsCert.name]"
|
||||||
:key="component.prop"
|
:key="component.prop"
|
||||||
:label="component.label"
|
:label="component.label"
|
||||||
:rules="component.rules"
|
:rules="component.rules"
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
:is="component.component"
|
:is="component.component"
|
||||||
:type="component.type"
|
:type="component.type"
|
||||||
v-model="letsCert[letsCert.name][component.prop]"
|
v-model="letsCert[letsCert.name][component.prop]"
|
||||||
></component>
|
></component>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-switch
|
<el-switch
|
||||||
style="display: block"
|
style="display: block"
|
||||||
v-model="letsCert.renew"
|
v-model="letsCert.renew"
|
||||||
active-color="#13ce66"
|
active-color="#13ce66"
|
||||||
inactive-color="#ff4949"
|
inactive-color="#ff4949"
|
||||||
inactive-text="自动续期"
|
inactive-text="自动续期"
|
||||||
>
|
>
|
||||||
</el-switch>
|
</el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('letsCert')"
|
<el-button type="primary" @click="submitForm('letsCert')"
|
||||||
>申请</el-button
|
>申请
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
<el-button @click="resetForm('letsCert')">重置</el-button>
|
<el-button @click="resetForm('letsCert')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -224,11 +230,11 @@
|
|||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="其他设置" name="dataOther">
|
<el-tab-pane label="其他设置" name="dataOther">
|
||||||
<el-form
|
<el-form
|
||||||
:model="dataOther"
|
:model="dataOther"
|
||||||
ref="dataOther"
|
ref="dataOther"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
label-width="100px"
|
label-width="130px"
|
||||||
class="tab-one"
|
class="tab-one"
|
||||||
>
|
>
|
||||||
<el-form-item label="vpn对外地址" prop="link_addr">
|
<el-form-item label="vpn对外地址" prop="link_addr">
|
||||||
<el-input placeholder="请输入内容" v-model="dataOther.link_addr">
|
<el-input placeholder="请输入内容" v-model="dataOther.link_addr">
|
||||||
@@ -237,49 +243,58 @@
|
|||||||
|
|
||||||
<el-form-item label="Banner信息" prop="banner">
|
<el-form-item label="Banner信息" prop="banner">
|
||||||
<el-input
|
<el-input
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="5"
|
:rows="5"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
v-model="dataOther.banner"
|
v-model="dataOther.banner"
|
||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="自定义首页状态码" prop="homecode">
|
||||||
|
<el-input-number
|
||||||
|
v-model="dataOther.homecode"
|
||||||
|
:min="0"
|
||||||
|
:max="1000"
|
||||||
|
></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="自定义首页" prop="homeindex">
|
<el-form-item label="自定义首页" prop="homeindex">
|
||||||
<el-input
|
<el-input
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="10"
|
:rows="10"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
v-model="dataOther.homeindex"
|
v-model="dataOther.homeindex"
|
||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
<el-tooltip content="自定义内容可以参考 home 目录下的文件" placement="top">
|
<el-tooltip content="自定义内容可以参考 index_template 目录下的文件" placement="top">
|
||||||
<i class="el-icon-question"></i>
|
<i class="el-icon-question"></i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="账户开通邮件" prop="account_mail">
|
<el-form-item label="账户开通邮件模板" prop="account_mail">
|
||||||
<el-input
|
<el-input
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="10"
|
:rows="10"
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
v-model="dataOther.account_mail"
|
v-model="dataOther.account_mail"
|
||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="邮件展示">
|
<el-form-item label="邮件展示">
|
||||||
<iframe
|
<iframe
|
||||||
width="500px"
|
width="500px"
|
||||||
height="300px"
|
height="300px"
|
||||||
:srcdoc="dataOther.account_mail"
|
:srcdoc="dataOther.account_mail"
|
||||||
>
|
>
|
||||||
</iframe>
|
</iframe>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm('dataOther')"
|
<el-button type="primary" @click="submitForm('dataOther')"
|
||||||
>保存</el-button
|
>保存
|
||||||
|
</el-button
|
||||||
>
|
>
|
||||||
<el-button @click="resetForm('dataOther')">重置</el-button>
|
<el-button @click="resetForm('dataOther')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -324,19 +339,19 @@ export default {
|
|||||||
authToken: "",
|
authToken: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
customCert: { cert: "", key: "" },
|
customCert: {cert: "", key: ""},
|
||||||
dataOther: {},
|
dataOther: {},
|
||||||
rules: {
|
rules: {
|
||||||
host: { required: true, message: "请输入服务器地址", trigger: "blur" },
|
host: {required: true, message: "请输入服务器地址", trigger: "blur"},
|
||||||
port: [
|
port: [
|
||||||
{ required: true, message: "请输入服务器端口", trigger: "blur" },
|
{required: true, message: "请输入服务器端口", trigger: "blur"},
|
||||||
{
|
{
|
||||||
type: "number",
|
type: "number",
|
||||||
message: "请输入正确的服务器端口",
|
message: "请输入正确的服务器端口",
|
||||||
trigger: ["blur", "change"],
|
trigger: ["blur", "change"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
issuer: { required: true, message: "请输入系统名称", trigger: "blur" },
|
issuer: {required: true, message: "请输入系统名称", trigger: "blur"},
|
||||||
domain: {
|
domain: {
|
||||||
required: true,
|
required: true,
|
||||||
message: "请输入需要申请证书的域名",
|
message: "请输入需要申请证书的域名",
|
||||||
@@ -347,7 +362,7 @@ export default {
|
|||||||
message: "请输入申请证书的邮箱地址",
|
message: "请输入申请证书的邮箱地址",
|
||||||
trigger: "blur",
|
trigger: "blur",
|
||||||
},
|
},
|
||||||
name: { required: true, message: "请选择域名服务商", trigger: "blur" },
|
name: {required: true, message: "请选择域名服务商", trigger: "blur"},
|
||||||
},
|
},
|
||||||
certUpload: "/set/other/customcert",
|
certUpload: "/set/other/customcert",
|
||||||
dnsProvider: {
|
dnsProvider: {
|
||||||
@@ -449,71 +464,71 @@ export default {
|
|||||||
},
|
},
|
||||||
getSmtp() {
|
getSmtp() {
|
||||||
axios
|
axios
|
||||||
.get("/set/other/smtp")
|
.get("/set/other/smtp")
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
let rdata = resp.data;
|
let rdata = resp.data;
|
||||||
console.log(rdata);
|
console.log(rdata);
|
||||||
if (rdata.code !== 0) {
|
if (rdata.code !== 0) {
|
||||||
this.$message.error(rdata.msg);
|
this.$message.error(rdata.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.dataSmtp = rdata.data;
|
this.dataSmtp = rdata.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$message.error("哦,请求出错");
|
this.$message.error("哦,请求出错");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAuditLog() {
|
getAuditLog() {
|
||||||
axios
|
axios
|
||||||
.get("/set/other/audit_log")
|
.get("/set/other/audit_log")
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
let rdata = resp.data;
|
let rdata = resp.data;
|
||||||
console.log(rdata);
|
console.log(rdata);
|
||||||
if (rdata.code !== 0) {
|
if (rdata.code !== 0) {
|
||||||
this.$message.error(rdata.msg);
|
this.$message.error(rdata.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.dataAuditLog = rdata.data;
|
this.dataAuditLog = rdata.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$message.error("哦,请求出错");
|
this.$message.error("哦,请求出错");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getletsCert() {
|
getletsCert() {
|
||||||
axios
|
axios
|
||||||
.get("/set/other/getcertset")
|
.get("/set/other/getcertset")
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
let rdata = resp.data;
|
let rdata = resp.data;
|
||||||
console.log(rdata);
|
console.log(rdata);
|
||||||
if (rdata.code !== 0) {
|
if (rdata.code !== 0) {
|
||||||
this.$message.error(rdata.msg);
|
this.$message.error(rdata.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.letsCert = Object.assign({}, this.letsCert, rdata.data);
|
this.letsCert = Object.assign({}, this.letsCert, rdata.data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$message.error("哦,请求出错");
|
this.$message.error("哦,请求出错");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getOther() {
|
getOther() {
|
||||||
axios
|
axios
|
||||||
.get("/set/other")
|
.get("/set/other")
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
let rdata = resp.data;
|
let rdata = resp.data;
|
||||||
console.log(rdata);
|
console.log(rdata);
|
||||||
if (rdata.code !== 0) {
|
if (rdata.code !== 0) {
|
||||||
this.$message.error(rdata.msg);
|
this.$message.error(rdata.msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.dataOther = rdata.data;
|
this.dataOther = rdata.data;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$message.error("哦,请求出错");
|
this.$message.error("哦,请求出错");
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
submitForm(formName) {
|
submitForm(formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
@@ -535,16 +550,16 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case "dataAuditLog":
|
case "dataAuditLog":
|
||||||
axios
|
axios
|
||||||
.post("/set/other/audit_log/edit", this.dataAuditLog)
|
.post("/set/other/audit_log/edit", this.dataAuditLog)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
var rdata = resp.data;
|
var rdata = resp.data;
|
||||||
console.log(rdata);
|
console.log(rdata);
|
||||||
if (rdata.code === 0) {
|
if (rdata.code === 0) {
|
||||||
this.$message.success(rdata.msg);
|
this.$message.success(rdata.msg);
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(rdata.msg);
|
this.$message.error(rdata.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "letsCert":
|
case "letsCert":
|
||||||
var loading = this.$loading({
|
var loading = this.$loading({
|
||||||
|
@@ -50,6 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<Cell left="软件版本" :right="system.sys.appVersion" divider/>
|
<Cell left="软件版本" :right="system.sys.appVersion" divider/>
|
||||||
<Cell left="软件CommitId" :right="system.sys.appCommitId" divider/>
|
<Cell left="软件CommitId" :right="system.sys.appCommitId" divider/>
|
||||||
|
<Cell left="软件BuildDate" :right="system.sys.appBuildDate" divider/>
|
||||||
<Cell left="GO系统" :right="system.sys.goOs" divider/>
|
<Cell left="GO系统" :right="system.sys.goOs" divider/>
|
||||||
<Cell left="GoArch" :right="system.sys.goArch" divider/>
|
<Cell left="GoArch" :right="system.sys.goArch" divider/>
|
||||||
<Cell left="GO版本" :right="system.sys.goVersion" divider/>
|
<Cell left="GO版本" :right="system.sys.goVersion" divider/>
|
||||||
|
@@ -13,23 +13,26 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-dropdown size="small" placement="bottom">
|
<el-dropdown size="small" placement="bottom">
|
||||||
<el-upload
|
<el-upload
|
||||||
class="uploaduser"
|
class="uploaduser"
|
||||||
action="uploaduser"
|
action="uploaduser"
|
||||||
accept=".xlsx, .xls"
|
accept=".xlsx, .xls"
|
||||||
:http-request="upLoadUser"
|
:http-request="upLoadUser"
|
||||||
:limit="1"
|
:limit="1"
|
||||||
:show-file-list="false">
|
:show-file-list="false">
|
||||||
<el-button size="small" icon="el-icon-upload2" type="primary">批量添加</el-button>
|
<el-button size="small" icon="el-icon-upload2" type="primary">批量添加</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item>
|
<el-dropdown-item>
|
||||||
<el-link style="font-size:12px;" type="success" href="批量添加用户模版.xlsx"><i class="el-icon-download"></i>下载模版</el-link>
|
<el-link style="font-size:12px;" type="success" href="批量添加用户模版.xlsx"><i
|
||||||
</el-dropdown-item>
|
class="el-icon-download"></i>下载模版
|
||||||
</el-dropdown-menu>
|
</el-link>
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="用户名:">
|
<el-form-item label="用户名或姓名或邮箱:">
|
||||||
<el-input size="small" v-model="searchData" placeholder="请输入内容" @keydown.enter.native="searchEnterFun"></el-input>
|
<el-input size="small" v-model="searchData" placeholder="请输入内容"
|
||||||
|
@keydown.enter.native="searchEnterFun"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@@ -105,7 +108,7 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag v-if="scope.row.status === 1" type="success">可用</el-tag>
|
<el-tag v-if="scope.row.status === 1" type="success">可用</el-tag>
|
||||||
<el-tag v-if="scope.row.status === 0" type="danger">停用</el-tag>
|
<el-tag v-if="scope.row.status === 0" type="danger">停用</el-tag>
|
||||||
<el-tag v-if="scope.row.status === 2" >过期</el-tag>
|
<el-tag v-if="scope.row.status === 2">过期</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
@@ -202,19 +205,20 @@
|
|||||||
|
|
||||||
<el-form-item label="过期时间" prop="limittime">
|
<el-form-item label="过期时间" prop="limittime">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="ruleForm.limittime"
|
v-model="ruleForm.limittime"
|
||||||
type="date"
|
type="date"
|
||||||
size="small"
|
size="small"
|
||||||
align="center"
|
align="center"
|
||||||
style="width:130px"
|
style="width:130px"
|
||||||
:picker-options="pickerOptions"
|
:picker-options="pickerOptions"
|
||||||
placeholder="选择日期">
|
placeholder="选择日期">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="禁用OTP" prop="disable_otp">
|
<el-form-item label="禁用OTP" prop="disable_otp">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="ruleForm.disable_otp">
|
v-model="ruleForm.disable_otp"
|
||||||
|
active-text="开启OTP后,用户密码为【PIN码+OTP动态码】(中间没有+号)">
|
||||||
</el-switch>
|
</el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@@ -278,7 +282,7 @@ export default {
|
|||||||
count: 10,
|
count: 10,
|
||||||
pickerOptions: {
|
pickerOptions: {
|
||||||
disabledDate(time) {
|
disabledDate(time) {
|
||||||
return time.getTime() < Date.now();
|
return time.getTime() < Date.now();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchData: '',
|
searchData: '',
|
||||||
@@ -324,7 +328,7 @@ export default {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", item.file);
|
formData.append("file", item.file);
|
||||||
axios.post('/user/uploaduser', formData, {
|
axios.post('/user/uploaduser', formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data'
|
||||||
}
|
}
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
@@ -456,15 +460,15 @@ export default {
|
|||||||
this.$refs[formName].resetFields();
|
this.$refs[formName].resetFields();
|
||||||
},
|
},
|
||||||
searchEnterFun(e) {
|
searchEnterFun(e) {
|
||||||
var keyCode = window.event ? e.keyCode : e.which;
|
var keyCode = window.event ? e.keyCode : e.which;
|
||||||
if (keyCode == 13) {
|
if (keyCode == 13) {
|
||||||
this.handleSearch()
|
this.handleSearch()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
this.searchData = "";
|
this.searchData = "";
|
||||||
this.handleSearch();
|
this.handleSearch();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,6 +1,59 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-card>
|
<el-card>
|
||||||
|
<el-form :inline="true">
|
||||||
|
<el-form-item>
|
||||||
|
<el-select
|
||||||
|
v-model="searchCate"
|
||||||
|
style="width: 86px;"
|
||||||
|
@change="handleSearch">
|
||||||
|
<el-option
|
||||||
|
label="用户名"
|
||||||
|
value="username">
|
||||||
|
</el-option>
|
||||||
|
<el-option
|
||||||
|
label="登录组"
|
||||||
|
value="group">
|
||||||
|
</el-option>
|
||||||
|
<el-option
|
||||||
|
label="MAC地址"
|
||||||
|
value="mac_addr">
|
||||||
|
</el-option>
|
||||||
|
<el-option
|
||||||
|
label="IP地址"
|
||||||
|
value="ip">
|
||||||
|
</el-option>
|
||||||
|
<el-option
|
||||||
|
label="远端地址"
|
||||||
|
value="remote_addr">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-input
|
||||||
|
v-model="searchText"
|
||||||
|
placeholder="请输入搜索内容"
|
||||||
|
@input="handleSearch">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
显示休眠用户:
|
||||||
|
<el-switch
|
||||||
|
v-model="showSleeper"
|
||||||
|
@change="handleSearch">
|
||||||
|
</el-switch>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
class="extra-small-button"
|
||||||
|
type="danger"
|
||||||
|
size="mini"
|
||||||
|
:loading="loadingOneOffline"
|
||||||
|
@click="handleOneOffline">
|
||||||
|
一键下线
|
||||||
|
</el-button>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
ref="multipleTable"
|
ref="multipleTable"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
@@ -20,14 +73,14 @@
|
|||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="group"
|
prop="group"
|
||||||
label="登陆组">
|
label="登录组">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="mac_addr"
|
prop="mac_addr"
|
||||||
label="MAC地址">
|
label="MAC地址">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="unique_mac"
|
prop="unique_mac"
|
||||||
label="唯一MAC">
|
label="唯一MAC">
|
||||||
@@ -67,7 +120,6 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="status"
|
|
||||||
label="实时 上行/下行"
|
label="实时 上行/下行"
|
||||||
width="220">
|
width="220">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -77,7 +129,6 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="status"
|
|
||||||
label="总量 上行/下行"
|
label="总量 上行/下行"
|
||||||
width="200">
|
width="200">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -88,7 +139,7 @@
|
|||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="last_login"
|
prop="last_login"
|
||||||
label="登陆时间"
|
label="登录时间"
|
||||||
:formatter="tableDateFormat">
|
:formatter="tableDateFormat">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
@@ -99,6 +150,7 @@
|
|||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
v-if="scope.row.remote_addr !== ''"
|
||||||
@click="handleReline(scope.row)">重连
|
@click="handleReline(scope.row)">重连
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
@@ -123,6 +175,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { MessageBox } from 'element-ui';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Online",
|
name: "Online",
|
||||||
@@ -147,6 +200,10 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tableData: [],
|
tableData: [],
|
||||||
|
searchCate: 'username',
|
||||||
|
searchText: '',
|
||||||
|
showSleeper: false,
|
||||||
|
loadingOneOffline: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -185,8 +242,43 @@ export default {
|
|||||||
handleEdit(a, row) {
|
handleEdit(a, row) {
|
||||||
console.log(a, row)
|
console.log(a, row)
|
||||||
},
|
},
|
||||||
|
handleOneOffline() {
|
||||||
|
if (this.tableData === null || this.tableData.length === 0) {
|
||||||
|
this.$message.error('错误:当前在线用户表为空,无法执行一键下线操作!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MessageBox.confirm('当前搜索条件下的所有用户将会“下线”,你确定执行吗?', '危险', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'danger'
|
||||||
|
}).then(() => {
|
||||||
|
try {
|
||||||
|
this.loadingOneOffline = true;
|
||||||
|
this.getData();
|
||||||
|
this.$message.success('操作成功');
|
||||||
|
this.loadingOneOffline = false;
|
||||||
|
// 清空当前表格
|
||||||
|
this.tableData = [];
|
||||||
|
} catch (error) {
|
||||||
|
this.loadingOneOffline = false;
|
||||||
|
this.$message.error('操作失败');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSearch() {
|
||||||
|
this.getData();
|
||||||
|
},
|
||||||
getData() {
|
getData() {
|
||||||
axios.get('/user/online').then(resp => {
|
axios.get('/user/online',
|
||||||
|
{
|
||||||
|
params: {
|
||||||
|
search_cate: this.searchCate,
|
||||||
|
search_text: this.searchText,
|
||||||
|
show_sleeper: this.showSleeper,
|
||||||
|
one_offline: this.loadingOneOffline
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).then(resp => {
|
||||||
var data = resp.data.data
|
var data = resp.data.data
|
||||||
console.log(data);
|
console.log(data);
|
||||||
this.tableData = data.datas;
|
this.tableData = data.datas;
|
||||||
@@ -201,5 +293,23 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
/deep/ .el-form .el-form-item__label,
|
||||||
|
/deep/ .el-form .el-form-item__content,
|
||||||
|
/deep/ .el-form .el-input,
|
||||||
|
/deep/ .el-form .el-select,
|
||||||
|
/deep/ .el-form .el-button,
|
||||||
|
/deep/ .el-form .el-select-dropdown__item {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
.el-select-dropdown .el-select-dropdown__item {
|
||||||
|
font-size: 11px;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
/deep/ .el-input__inner{
|
||||||
|
height: 30px;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
.extra-small-button {
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@@ -7,7 +7,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded
|
|||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
// 开发环境
|
// 开发环境
|
||||||
axios.defaults.baseURL = 'http://172.23.83.233:8800';
|
axios.defaults.baseURL = 'https://192.168.8.24:8800';
|
||||||
}
|
}
|
||||||
|
|
||||||
function request(vm) {
|
function request(vm) {
|
||||||
|
3951
web/yarn.lock
3951
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user