mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
添加path参数,可指定文件搜索路径;修正docker和docker-compose命令
This commit is contained in:
@@ -5,5 +5,5 @@ RUN git clone https://github.com/e1732a364fed/v2ray_simple.git . && \
|
||||
make -C ./cmd/verysimple
|
||||
|
||||
FROM alpine:latest
|
||||
COPY --from=builder /build/cmd/verysimple/verysimple /bin/verysimple
|
||||
ENTRYPOINT ["/bin/verysimple"]
|
||||
COPY --from=builder /build/cmd/verysimple/verysimple /etc/verysimple/verysimple
|
||||
ENTRYPOINT ["/etc/verysimple/verysimple"]
|
||||
|
||||
@@ -5,7 +5,6 @@ services:
|
||||
restart: always
|
||||
network_mode: "host"
|
||||
volumes:
|
||||
- "/etc/verysimple:/etc/verysimple"
|
||||
- "/etc/domain-list-community:/bin/geosite"
|
||||
command: -c /etc/verysimple/server.toml
|
||||
- "/etc/verysimple:/etc/verysimple_files"
|
||||
command: -path /etc/verysimple_files
|
||||
image: ghcr.io/e1732a364fed/v2ray_simple:latest
|
||||
|
||||
@@ -74,6 +74,7 @@ func init() {
|
||||
flag.BoolVar(&netLayer.UseReadv, "readv", netLayer.DefaultReadvOption, "toggle the use of 'readv' syscall")
|
||||
|
||||
flag.StringVar(&netLayer.GeoipFileName, "geoip", defaultGeoipFn, "geoip maxmind file name")
|
||||
flag.StringVar(&utils.ExtraSearchPath, "path", "", "search path for mmdb, geosite and other required files")
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -123,10 +123,8 @@ https://github.com/e1732a364fed/v2ray_simple/pkgs/container/v2ray_simple
|
||||
|
||||
在含有 docker-compose.yaml 的目录下,运行 `docker-compose up -d` 来启动;运行 `docker-compose down` 来关闭。
|
||||
|
||||
这个docker-compose 设计时,要求你 宿主机有一个 `/etc/verysimple` 文件夹,里面放 一个 `server.toml` 配置文件。
|
||||
这个docker-compose 设计时,要求你 宿主机有一个 `/etc/verysimple` 文件夹,里面放 一个 `server.toml` 配置文件。 其他mmdb或者 geosite文件夹 如果有需要,也可以放入 /etc/verysimple 中
|
||||
|
||||
还要求你宿主机的 `/etc/domain-list-community` 文件夹 为 geosite 文件夹 (内有data文件夹,data文件夹内部有很多文件,文件格式等同于 v2fly/domain-list-community 项目中的 data文件夹 中的 文件 的格式)。
|
||||
|
||||
如果你没有这个文件夹或者没有这个文件,则该 docker-compose 肯定运行不了。当然,你可以自行修改 该 `docker-compose.yaml` 文件
|
||||
你可以自行修改 该 `docker-compose.yaml` 文件
|
||||
|
||||
(我没试过,如果有错误请指正)
|
||||
|
||||
@@ -13,6 +13,10 @@ const (
|
||||
ProjectPath = ProjectName + "/"
|
||||
)
|
||||
|
||||
var (
|
||||
ExtraSearchPath = "" //若给出,则会优先在此路径里查找
|
||||
)
|
||||
|
||||
func FileExist(path string) bool {
|
||||
_, err := os.Lstat(path)
|
||||
return !os.IsNotExist(err)
|
||||
@@ -44,11 +48,12 @@ func IsFilePath(s string) error {
|
||||
}
|
||||
|
||||
// Function that search the specified file in the following directories:
|
||||
// -1. if starts with '/', or is an empty string, return directly
|
||||
// 0. if starts with string similar to "C:/", "D:\\", or "e:/", return directly
|
||||
// 1. Same folder with exec file
|
||||
// 2. Same folder of the source file, 一种可能 是 用于 go test等情况
|
||||
// 3. Same folder of working folder
|
||||
// -1. If starts with '/', or is an empty string, return directly
|
||||
// 0. If starts with string similar to "C:/", "D:\\", or "e:/", return directly
|
||||
// 1. Search in ExtraSearchPath
|
||||
// 2. Same folder with exec file
|
||||
// 3. Same folder of the source file, 一种可能 是 用于 go test等情况
|
||||
// 4. Same folder of working folder
|
||||
func GetFilePath(fileName string) string {
|
||||
if len(fileName) < 1 {
|
||||
return ""
|
||||
@@ -63,6 +68,13 @@ func GetFilePath(fileName string) string {
|
||||
return fileName
|
||||
}
|
||||
|
||||
if ExtraSearchPath != "" {
|
||||
p := filepath.Join(filepath.Dir(ExtraSearchPath), fileName)
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
if execFile, err := os.Executable(); err == nil {
|
||||
p := filepath.Join(filepath.Dir(execFile), fileName)
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user