mirror of
https://github.com/nitezs/sub2sing-box.git
synced 2024-12-23 20:54:42 -05:00
fix: docker
This commit is contained in:
parent
3feeb66f68
commit
7f4ee70cb7
@ -16,6 +16,13 @@ builds:
|
||||
flags:
|
||||
- -trimpath
|
||||
no_unique_dist_dir: true
|
||||
binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
|
||||
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
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
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:
|
||||
sub2sing-box:
|
||||
image: nite07/sub2sing-box:latest
|
||||
image: nite07/sub2sing-box:dev # nite07/sub2sing-box:latest
|
||||
container_name: sub2sing-box
|
||||
volumes:
|
||||
- ./template:/app/template
|
||||
- ./templates:/app/templates
|
||||
ports:
|
||||
- 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"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@ -97,6 +98,11 @@ func Convert(subscriptions []string, proxies []string, template string, delete s
|
||||
}
|
||||
|
||||
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)
|
||||
proxyTags := make([]string, 0)
|
||||
if err != nil {
|
||||
@ -115,7 +121,6 @@ func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
for i, outbound := range config.Outbounds {
|
||||
if outbound.Type == "urltest" || outbound.Type == "selector" {
|
||||
var parsedOutbound []string = make([]string, 0)
|
||||
for _, o := range outbound.Outbounds {
|
||||
if o == "<all-proxy-tags>" {
|
||||
@ -126,8 +131,8 @@ func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
|
||||
}
|
||||
config.Outbounds[i].Outbounds = parsedOutbound
|
||||
}
|
||||
}
|
||||
config.Outbounds = append(config.Outbounds, newOutbounds...)
|
||||
//TODO: 国家策略组
|
||||
data, err := json.Marshal(config)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -257,3 +262,20 @@ func RenameProxy(proxies []model.Proxy, regex string, replaceText string) ([]mod
|
||||
}
|
||||
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