mirror of
https://github.com/nitezs/sub2sing-box.git
synced 2024-12-24 11:04:42 -05:00
fix: docker
This commit is contained in:
parent
3feeb66f68
commit
7f4ee70cb7
@ -16,6 +16,13 @@ builds:
|
|||||||
flags:
|
flags:
|
||||||
- -trimpath
|
- -trimpath
|
||||||
no_unique_dist_dir: true
|
no_unique_dist_dir: true
|
||||||
binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
|
|
||||||
archives:
|
archives:
|
||||||
- format: binary
|
- format: tar.gz
|
||||||
|
format_overrides:
|
||||||
|
- format: zip
|
||||||
|
goos: windows
|
||||||
|
wrap_in_directory: true
|
||||||
|
files:
|
||||||
|
- LICENSE
|
||||||
|
- README.md
|
||||||
|
- templates
|
||||||
|
12
Dockerfile
12
Dockerfile
@ -10,9 +10,17 @@ ARG version
|
|||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2clash/config.Version=${version}" -o sub2sing-box main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X sub2clash/config.Version=${version}" -o sub2sing-box main.go
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
COPY --from=builder /app/sub2sing-box /app/sub2sing-box
|
COPY --from=builder /app/sub2sing-box /app/sub2sing-box
|
||||||
COPY --from=builder /app/template /app/template
|
COPY --from=builder /app/templates /app/templates-origin
|
||||||
|
COPY --from=builder /app/entrypoint.sh /app/entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/app/sub2sing-box","server"]
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
VOLUME [ "/app/templates" ]
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
version: "3.8"
|
||||||
services:
|
services:
|
||||||
sub2sing-box:
|
sub2sing-box:
|
||||||
image: nite07/sub2sing-box:latest
|
image: nite07/sub2sing-box:dev # nite07/sub2sing-box:latest
|
||||||
container_name: sub2sing-box
|
container_name: sub2sing-box
|
||||||
volumes:
|
volumes:
|
||||||
- ./template:/app/template
|
- ./templates:/app/templates
|
||||||
ports:
|
ports:
|
||||||
- 8080:8080
|
- 8080:8080
|
9
entrypoint.sh
Normal file
9
entrypoint.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ ! -d "/app/templates" ]; then
|
||||||
|
mkdir /app/templates
|
||||||
|
fi
|
||||||
|
if [ -z "$(ls -A /app/templates)" ]; then
|
||||||
|
cp -r /app/templates-origin/* /app/templates
|
||||||
|
fi
|
||||||
|
cd /app
|
||||||
|
/app/sub2sing-box server
|
1044
internal/model/country_code_map.go
Normal file
1044
internal/model/country_code_map.go
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -97,6 +98,11 @@ func Convert(subscriptions []string, proxies []string, template string, delete s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
|
func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
|
||||||
|
if !strings.Contains(template, string(filepath.Separator)) {
|
||||||
|
if _, err := os.Stat(template); os.IsNotExist(err) {
|
||||||
|
template = filepath.Join("templates", template)
|
||||||
|
}
|
||||||
|
}
|
||||||
config, err := ReadTemplate(template)
|
config, err := ReadTemplate(template)
|
||||||
proxyTags := make([]string, 0)
|
proxyTags := make([]string, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -115,19 +121,18 @@ func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
for i, outbound := range config.Outbounds {
|
for i, outbound := range config.Outbounds {
|
||||||
if outbound.Type == "urltest" || outbound.Type == "selector" {
|
var parsedOutbound []string = make([]string, 0)
|
||||||
var parsedOutbound []string = make([]string, 0)
|
for _, o := range outbound.Outbounds {
|
||||||
for _, o := range outbound.Outbounds {
|
if o == "<all-proxy-tags>" {
|
||||||
if o == "<all-proxy-tags>" {
|
parsedOutbound = append(parsedOutbound, proxyTags...)
|
||||||
parsedOutbound = append(parsedOutbound, proxyTags...)
|
} else {
|
||||||
} else {
|
parsedOutbound = append(parsedOutbound, o)
|
||||||
parsedOutbound = append(parsedOutbound, o)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
config.Outbounds[i].Outbounds = parsedOutbound
|
|
||||||
}
|
}
|
||||||
|
config.Outbounds[i].Outbounds = parsedOutbound
|
||||||
}
|
}
|
||||||
config.Outbounds = append(config.Outbounds, newOutbounds...)
|
config.Outbounds = append(config.Outbounds, newOutbounds...)
|
||||||
|
//TODO: 国家策略组
|
||||||
data, err := json.Marshal(config)
|
data, err := json.Marshal(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -257,3 +262,20 @@ func RenameProxy(proxies []model.Proxy, regex string, replaceText string) ([]mod
|
|||||||
}
|
}
|
||||||
return proxies, nil
|
return proxies, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetContryName(proxyName string) string {
|
||||||
|
countryMaps := []map[string]string{
|
||||||
|
model.CountryFlag,
|
||||||
|
model.CountryChineseName,
|
||||||
|
model.CountryISO,
|
||||||
|
model.CountryEnglishName,
|
||||||
|
}
|
||||||
|
for _, countryMap := range countryMaps {
|
||||||
|
for k, v := range countryMap {
|
||||||
|
if strings.Contains(proxyName, k) {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "其他地区"
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user