From ab5167049e9591aaa7445921cf8d735e38a18647 Mon Sep 17 00:00:00 2001 From: ycvk Date: Thu, 20 Jun 2024 17:41:02 +0800 Subject: [PATCH] =?UTF-8?q?#27=20feat=20=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.go | 1 + main.go | 2 +- readme.md | 17 +++- url.txt | 221 ++++++++++++++---------------------------- web/deeplx_handler.go | 15 ++- 5 files changed, 99 insertions(+), 157 deletions(-) diff --git a/init.go b/init.go index 18dae9b..e99f3de 100644 --- a/init.go +++ b/init.go @@ -28,6 +28,7 @@ var ( client = req.NewClient().SetTimeout(3 * time.Second) hunterKey = os.Getenv("hunter_api_key") quakeKey = os.Getenv("360_api_key") + routePath = os.Getenv("route") scanService service.ScanService ) diff --git a/main.go b/main.go index ea19407..341dc34 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func initServer() { gin.SetMode(gin.ReleaseMode) r := gin.Default() balancerService := service.NewLoadBalancer(&urLs) - lxHandler := web.NewDeepLXHandler(balancerService) + lxHandler := web.NewDeepLXHandler(balancerService, routePath) lxHandler.RegisterRoutes(r) go func() { diff --git a/readme.md b/readme.md index 2d09e2b..78dca53 100644 --- a/readme.md +++ b/readme.md @@ -12,10 +12,18 @@ **翻译地址:**`http://localhost:8080/translate` + +添加 `route`环境变量可修改默认翻译地址, 如: + +`docker run --pull=always -itd -p 8080:62155 -e route=abc neccen/deeplx-local:latest` + +翻译地址为`http://localhost:8080/abc` + ### 可选参数 +- `route`:默认为`/translate`,可自定义翻译地址。比如设置为 `abc`,则翻译地址为 `http://localhost:8080/abc` - `360_api_key`:[quake360](https://quake.360.net/quake/#/personal?tab=message)的api_key,可用于每日自动爬取更多的翻译接口。(有每日免费次数) - `hunter_api_key`:[鹰图](https://hunter.qianxin.com/home/myInfo)的api_key,可用于每日自动爬取更多的翻译接口。(有每日免费次数) -- 群友提到的`fofa`不想加,不送免费额度啊,本来想用[Cl0udG0d/Fofa-hack: 非付费会员,fofa数据采集工具](https://github.com/Cl0udG0d/Fofa-hack)偷个懒,发现不传自己的auth会有20条搜索的限制,懒得整了 +- 提到的`fofa`不想加,不送免费额度,本来想用[Cl0udG0d/Fofa-hack: 非付费会员,fofa数据采集工具](https://github.com/Cl0udG0d/Fofa-hack)偷个懒,发现不传自己的auth会有20条搜索的限制,不整了 ### 使用方法 @@ -25,11 +33,13 @@ -`docker run -itd -p 62155:62155 neccen/deeplx-local:latest` +`docker run -itd -p 8080:62155 neccen/deeplx-local:latest` + +翻译地址为 `http://localhost:8080/translate` ##### 完整命令: -`docker run -itd -p 62155:62155 -v /url.txt文件目录:/usr/local/bin/url.txt -e 360_api_key="xxxxx" neccen/deeplx-local:latest` +`docker run -itd -p 8080:62155 -v /url.txt文件目录:/usr/local/bin/url.txt -e route xxx -e 360_api_key="xxxxx" neccen/deeplx-local:latest` #### 2. Docker Compose 运行 @@ -43,6 +53,7 @@ services: volumes: - /url.txt文件目录:/usr/local/bin/url.txt # 本地url.txt文件目录,删除此行则使用内置的已经爬取的deeplx翻译接口 environment: + - route=xxx # 可选 默认为 /translate - 360_api_key=xxxxx # 可选 - hunter_api_key=xxxxx # 可选 container_name: deeplx diff --git a/url.txt b/url.txt index 78c3ad4..249986e 100644 --- a/url.txt +++ b/url.txt @@ -1,256 +1,179 @@ -http://deeplx.6666666666.link:80/translate -https://deeplx.6666666666.link:443/translate -http://51.81.187.241:1188/translate http://101.43.11.30:9188/translate -http://deeplx-pro.989995.xyz:80/translate -https://deeplx-pro.989995.xyz:443/translate http://129.80.43.129:9000/translate -http://13.213.64.250:1188/translate -https://deeplx.gzcrtw.com:443/translate -http://deeplx.gzcrtw.com:80/translate +http://51.81.187.241:1188/translate +https://deeplx-pro.989995.xyz:443/translate +http://deeplx-pro.989995.xyz:80/translate +http://142.171.139.254:1188/translate +http://103.100.176.147:1188/translate http://hztian.online:1188/translate http://124.220.50.132:1188/translate -http://deeplx.ymurphy.top:80/translate -https://deeplx.ymurphy.top:443/translate http://nat.finalspeed.cc:1188/translate -http://142.171.139.254:1188/translate -http://103.100.176.147:1188/translate -https://deeplx.xcty.gq/translate http://119.3.6.116:1188/translate -https://deeplx.topnec.org/translate http://194.87.252.161:1188/translate -https://translate.smurl1.asia/translate -http://47.236.84.103:9000/translate http://74.48.183.216:8082/translate -http://88.151.33.155:8006/translate http://107.150.100.170:8880/translate -https://deepl.imyrs.net/translate +https://deeplx.ymurphy.top:443/translate +http://deeplx.ymurphy.top:80/translate +http://88.151.33.155:8006/translate +http://121.199.78.234:1188/translate http://146.235.18.76:9090/translate +http://8.138.99.112:1188/translate http://142.171.26.166:1010/translate -https://dx.mmyy.fun/translate -http://ssk.wiki:1188/translate http://129.159.77.159:1188/translate -http://121.199.78.234:1188/translate -http://8.138.99.112:1188/translate -http://192.9.137.158:1188/translate -https://deeplx.qiud.org/translate -http://192.3.60.182:1188/translate http://132.232.103.239:1188/translate +http://ssk.wiki:1188/translate http://92.53.104.48:1188/translate -https://deeplx.qninq.cn/translate +http://192.3.60.182:1188/translate http://154.23.244.83:1188/translate http://8.219.242.203:1188/translate http://107.174.255.56:1188/translate +http://142.171.42.182:1188/translate http://121.40.157.111:1188/translate +https://deeplx.qiud.org/translate http://107.148.28.180:1188/translate -http://47.116.15.9:1188/translate -http://142.171.42.182:1188/translate -http://158.101.148.105:1188/translate http://39.105.187.136:1188/translate http://47.243.35.229:1188/translate +http://158.101.148.105:1188/translate +http://47.116.15.9:1188/translate +http://101.43.53.11:1188/translate http://23.94.223.163:1188/translate +http://47.116.2.214:1188/translate +https://deeplx.qninq.cn/translate http://47.242.32.140:1188/translate http://43.138.46.231:1188/translate -http://101.43.53.11:1188/translate -http://1.12.229.77:1188/translate http://103.114.163.237:1188/translate +http://1.12.229.77:1188/translate http://51.79.33.25:1188/translate -http://120.46.163.33:1188/translate -http://47.116.2.214:1188/translate -http://178.128.212.121:1188/translate -http://158.180.64.131:1188/translate http://107.175.28.239:1188/translate +http://158.180.64.131:1188/translate http://106.55.57.193:1188/translate -http://84.247.145.58:1188/translate http://207.148.30.41:1188/translate http://119.28.77.231:1188/translate +http://120.46.163.33:1188/translate +http://52.194.218.139:1188/translate http://116.203.189.170:1188/translate http://154.38.173.255:1188/translate -http://52.194.218.139:1188/translate +http://148.135.65.141:1188/translate http://103.151.40.130:1188/translate +http://103.247.28.40:1188/translate http://45.77.180.102:1188/translate -http://148.135.65.141:1188/translate -http://132.226.172.234:1188/translate http://37.120.189.116:1188/translate -http://103.247.28.40:1188/translate -http://18.183.159.207:1188/translate http://43.129.249.234:1188/translate -http://192.210.196.117:1188/translate -http://43.156.58.228:1188/translate +http://178.128.212.121:1188/translate +http://132.226.172.234:1188/translate +http://146.56.156.60:1188/translate http://129.146.67.74:1188/translate -http://192.3.127.63:1188/translate http://47.236.22.51:1188/translate -http://146.56.156.60:1188/translate -http://120.55.53.234:1188/translate -http://66.42.70.201:1188/translate -http://75.127.0.166:1188/translate +http://192.3.127.63:1188/translate http://119.91.141.30:1188/translate -http://158.178.247.29:1188/translate -http://120.55.63.151:1188/translate -http://74.48.19.200:1188/translate +http://75.127.0.166:1188/translate http://101.43.224.133:1188/translate -https://dxn.mmyy.fun/translate +http://158.178.247.29:1188/translate http://107.172.8.146:1188/translate -http://148.135.98.234:1188/translate -http://www1.0860523.top:1188/translate -http://165.154.5.156:1188/translate http://142.171.59.190:1188/translate -http://43.132.160.253:1188/translate -http://121.41.99.203:1188/translate -http://109.206.245.73:1188/translate http://5.252.226.8:1188/translate -http://43.130.10.231:1188/translate -http://138.2.95.93:1188/translate http://20.89.43.13:1188/translate http://81.70.207.129:1188/translate -http://47.236.38.78:1188/translate -http://193.32.149.239:1188/translate -http://168.138.161.222:1188/translate http://47.242.206.190:1188/translate -http://139.224.191.20:1188/translate -http://158.101.157.53:1188/translate +http://47.236.38.78:1188/translate http://43.153.38.254:1188/translate +http://168.138.161.222:1188/translate http://150.230.46.11:1188/translate http://194.233.71.122:1188/translate http://47.119.172.46:1188/translate -http://192.9.147.173:1188/translate http://176.126.114.231:1188/translate -http://148.135.124.106:1188/translate +http://192.9.147.173:1188/translate http://23.94.104.174:1188/translate -http://202.91.34.119:1188/translate http://141.147.151.154:1188/translate -http://152.67.213.75:1188/translate http://43.143.233.18:1188/translate -http://47.109.98.57:1188/translate -http://104.214.145.200:1188/translate http://168.138.161.149:1188/translate -http://82.157.49.14:1188/translate -http://119.28.13.127:1188/translate -http://170.64.190.34:1188/translate +http://202.91.34.119:1188/translate http://38.47.98.127:1188/translate +http://170.64.190.34:1188/translate http://158.247.197.25:1188/translate -http://192.210.142.53:1188/translate -http://165.154.203.71:1188/translate -http://39.98.115.99:1188/translate -http://142.171.218.100:1188/translate http://150.158.45.100:1188/translate -http://8.134.151.104:1188/translate +http://142.171.218.100:1188/translate http://42.192.21.116:1188/translate -http://185.106.209.123:1188/translate +http://121.43.134.47:1188/translate http://211.227.72.101:1188/translate +http://185.106.209.123:1188/translate http://107.172.137.246:1188/translate -http://148.135.58.49:1188/translate -http://121.43.134.47:1188/translate -http://142.171.74.214:1188/translate -http://144.24.94.118:1188/translate -http://43.134.189.147:1188/translate -http://139.224.225.116:1188/translate http://39.105.60.208:1188/translate http://47.103.194.159:1188/translate http://45.152.67.153:1188/translate -http://39.100.95.114:1188/translate http://34.97.37.189:1188/translate +http://139.224.225.116:1188/translate http://124.220.101.194:1188/translate -http://52.140.204.252:1188/translate -http://79.137.205.255:1188/translate -http://107.189.1.3:1188/translate http://101.133.234.93:1188/translate http://81.70.94.105:1188/translate -http://141.11.90.131:1188/translate -http://123.56.13.17:1188/translate +http://79.137.205.255:1188/translate http://107.174.88.163:1188/translate -http://150.230.108.185:1188/translate -http://124.221.198.187:1188/translate -http://104.168.22.220:1188/translate -http://20.89.129.172:1188/translate http://1.14.59.89:1188/translate http://120.79.93.103:1188/translate http://43.134.250.154:1188/translate -http://146.56.111.178:1188/translate http://146.56.165.8:1188/translate +http://150.230.46.219:8136/translate http://139.99.66.128:1188/translate +http://20.89.129.172:1188/translate http://15.228.190.225:12294/translate -http://150.230.46.219:8136/translate -http://deeplx.wslmf.com:80/translate -https://deeplx.wslmf.com:443/translate -https://deeplx.ou.al:443/translate -https://translate.erronliu.top:443/translate https://deeplx.xhazy.top:443/translate +https://deeplx.uyki.top:443/translate +https://deeplx.ou.al:443/translate +https://translate.getaigpt.com:443/translate +https://v2.555757.xyz:443/translate https://deeplx.8512426.xyz:8443/translate http://deeplx.8512426.xyz:80/translate https://deeplx.8512426.xyz:443/translate -https://translate.getaigpt.com:443/translate -https://v2.555757.xyz:443/translate -https://deeplx.uyki.top:443/translate +http://120.46.71.167:1188/translate https://tr.56.kg:443/translate -https://deeplx.papercar.top:443/translate -https://deeplx.ywzsqx.top:443/translate -http://deeplx.ywzsqx.top:80/translate http://61.71.167.116:8015/translate -https://deeplx.autmaple.com:443/translate -http://120.46.71.167:1188/translate +http://8.134.81.54:60005/translate https://translate.ipenguin.top:443/translate http://translate.ipenguin.top:80/translate -http://8.134.81.54:60005/translate +https://deeplx.autmaple.com:443/translate https://dplx.imirai.xyz:443/translate -https://gpay.eu.org:443/translate -https://deeplx.233.at:443/translate -https://dlx.iyuanshuo.com:443/translate +http://150.230.254.8:9033/translate +https://dplx.imirai.xyz:2087/translate https://trsapi-dp.owu.one:443/translate -https://dx.mmyy.fun:443/translate +https://dplx.imirai.xyz:2053/translate http://deeplx.72521.xyz:80/translate https://deeplx.72521.xyz:443/translate -https://dxn.mmyy.fun:443/translate -http://150.230.254.8:9033/translate -http://113.45.191.39:1188/translate https://deeplx.mmyy.fun:443/translate -https://dplx.imirai.xyz:2087/translate -https://dplx.imirai.xyz:2053/translate +http://113.45.191.39:1188/translate +https://deeplx.233.at:443/translate http://platform.tt009.net:12290/translate -http://deepl.dd4.flier001.top:80/translate -https://deepl.dd4.flier001.top:443/translate -https://deeplx.huiaei.eu.org:2096/translate -https://deeplx.huiaei.eu.org:2087/translate +http://deeplx.0x318.com:80/translate http://translate.z7ge.com:80/translate -http://deeplx.huiaei.eu.org:2052/translate -https://deeplx.uid.si:443/translate http://deeplx.xukecheng.tech:80/translate -http://deeplx.0x318.com:80/translate https://deeplx.xukecheng.tech:443/translate -https://deepl.imyrs.net:443/translate +https://deeplx.uid.si:443/translate https://deepl.mukapp.top:443/translate -https://deeplx.qikepai.cn:443/translate +https://deeplx.huiaei.eu.org:2087/translate https://deeplx.onshadow.cn:443/translate +https://dplx.imirai.xyz:2096/translate https://deeplx.0x318.com:443/translate +http://eridal.asuscomm.com:51004/translate +http://kr.v2root.com:9033/translate +https://dplx.imirai.xyz:2083/translate +http://s1.ijoyvm.com:9033/translate https://deeplx.littleblack111.com:443/translate -https://dplx.imirai.xyz:2096/translate http://deepl.embest.net:80/translate https://deepl.embest.net:443/translate -http://eridal.asuscomm.com:51004/translate -http://deeplx.huiaei.eu.org:8880/translate +https://deeplx.qikepai.cn:443/translate http://deeplx.61183788.xyz:80/translate -http://kr.v2root.com:9033/translate -http://deeplx.171826.xyz:80/translate -http://s1.ijoyvm.com:9033/translate -https://dplx.imirai.xyz:2083/translate http://trsapi-dp.owu.one:80/translate -https://deepl.yuwentian.com:443/translate http://15.228.190.225:12290/translate -https://fy.61183788.xyz:443/translate http://fy.61183788.xyz:80/translate +https://fy.61183788.xyz:443/translate +http://pwd.ake1.com:8082/translate +http://deeplx.171826.xyz:80/translate +https://deepl.yuwentian.com:443/translate https://deeplx.guyv.top:443/translate -http://dplx.inavoni.top:80/translate https://deepl.llost.net:443/translate -http://pwd.ake1.com:8082/translate -https://deeplx.yich.me:2087/translate -http://deeplx.yich.me:2086/translate -https://deeplx.yich.me:2096/translate -http://deeplx.yich.me:2082/translate -http://deeplx.yich.me:2095/translate -https://deeplx.yich.me:443/translate -http://168.138.160.146:9000/translate -http://139.59.118.24:1188/translate -http://116.204.31.185:1188/translate http://deeplx.8512426.xyz:8080/translate +http://dplx.inavoni.top:80/translate +http://116.204.31.185:1188/translate +http://139.59.118.24:1188/translate https://deeplx.rua.dev:2083/translate +http://168.138.160.146:9000/translate https://api.proxy.deepl.root.me:443/translate \ No newline at end of file diff --git a/web/deeplx_handler.go b/web/deeplx_handler.go index a1f5a3f..eae8962 100644 --- a/web/deeplx_handler.go +++ b/web/deeplx_handler.go @@ -8,11 +8,18 @@ import ( ) type DeepLXHandler struct { - service service.TranslateService + service service.TranslateService + routePath string } -func NewDeepLXHandler(service service.TranslateService) *DeepLXHandler { - return &DeepLXHandler{service: service} +func NewDeepLXHandler(service service.TranslateService, customRoute string) *DeepLXHandler { + if customRoute == "" { + customRoute = "/translate" + } + if customRoute[0] != '/' { + customRoute = "/" + customRoute + } + return &DeepLXHandler{service: service, routePath: customRoute} } func (d *DeepLXHandler) Translate(c *gin.Context) { @@ -27,5 +34,5 @@ func (d *DeepLXHandler) Translate(c *gin.Context) { } func (d *DeepLXHandler) RegisterRoutes(engine *gin.Engine) { - engine.POST("/translate", d.Translate) + engine.POST(d.routePath, d.Translate) }