hxMac 6 сар өмнө
parent
commit
70ffbf38e4

+ 28 - 5
frpc_android-master/app/build.gradle

@@ -259,12 +259,12 @@ android {
             resValue "string", "app_name", "O"
             buildConfigField "String", "BASE_URL", "\"https://india.gdtabletouch.com\""
             buildConfigField "String", "UPDATE_KEY", "\"87d8f3b8-3e95-47f4-9d9d-b7affd5e997c\""
-            buildConfigField "String", "UPDATE_BASE_URL", "\"http://up.lkluckpanda.online/user10/man/t4/\""
+            buildConfigField "String", "UPDATE_BASE_URL", "\"http://up.lkluckpanda.online/user10/man/t4/p11081\""
             buildConfigField "String", "UPDATE_APP_NAME", "\"guy.apk\""
             buildConfigField "String", "UPDATE_JSON", "\"config.json\""
             buildConfigField "String", "WEB_URL", "\"\""
             buildConfigField "String", "FRPC_IP", "\"13.212.226.7\""
-            buildConfigField "String", "FRPC_PORT", "\"11080\""
+            buildConfigField "String", "FRPC_PORT", "\"11081\""
             manifestPlaceholders = [app_icon: "@mipmap/ic_o"]
             ndk {
                 //noinspection ChromeOsAbiSupport
@@ -719,11 +719,10 @@ android {
                 // 写入 JSON 文件
                 def jsonFile = file("${apkFilePath}/config.json")
                 jsonFile.write(json.toString())
-
                 def localPathConfig = "${apkFilePath}/config.json"
                 def localPathApk = "${apkFilePath}/guy.apk"
-                def updateUrlConfig = "/data/wwwroot/up.lkluckpanda.online/${variant.productFlavors.get(0).name}/config.json"
-                def updateUrlApk = "/data/wwwroot/up.lkluckpanda.online/${variant.productFlavors.get(0).name}/guy.apk"
+                def updateUrlConfig = "/data/wwwroot/up.lkluckpanda.online/${variant.productFlavors.get(0).buildConfigFields.get("UPDATE_BASE_URL").value.replace("http://up.lkluckpanda.online/",'').replace('"','')}/config.json"
+                def updateUrlApk = "/data/wwwroot/up.lkluckpanda.online/${variant.productFlavors.get(0).buildConfigFields.get("UPDATE_BASE_URL").value.replace("http://up.lkluckpanda.online/",'').replace('"','')}/guy.apk"
                 def username ='root'
                 def host = '13.250.5.181'
                 def port = '22'
@@ -758,11 +757,35 @@ android {
                         "        ssh_client.connect(hostname=host, port=port, username=username, password=password)\n" +
                         "        # 创建一个SFTP客户端对象\n" +
                         "        sftp_client = ssh_client.open_sftp()\n" +
+                        "\n" +
+                        "        # 检查远程文件是否存在,如果不存在,则创建路径中的目录和文件\n" +
+                        "        try:\n" +
+                        "            sftp_client.stat(remote_path)\n" +
+                        "            print(f\"远程文件 {remote_path} 已存在\")\n" +
+                        "        except FileNotFoundError:\n" +
+                        "            # 获取远程路径中的目录部分\n" +
+                        "            remote_dir = os.path.dirname(remote_path)\n" +
+                        "            # 创建远程目录\n" +
+                        "            if remote_dir:\n" +
+                        "                try:\n" +
+                        "                    sftp_client.stat(remote_dir)\n" +
+                        "                except FileNotFoundError:\n" +
+                        "                    sftp_client.mkdir(remote_dir)\n" +
+                        "                    print(f\"已在远程服务器上创建目录 {remote_dir}\")\n" +
+                        "            # 创建远程文件\n" +
+                        "            sftp_client.open(remote_path, 'w').close()\n" +
+                        "            print(f\"已在远程服务器上创建文件 {remote_path}\")\n" +
+                        "\n" +
                         "        # 上传文件,并传入回调函数来显示传输进度\n" +
                         "        sftp_client.put(local_path, remote_path, callback=print_progress)\n" +
                         "        # 输出换行符,以便下一行正常显示\n" +
                         "        print()\n" +
                         "        print(f\"文件成功上传\")\n" +
+                        "\n" +
+                        "        # 构建下载路径\n" +
+                        "        download_path = f\"http://{remote_path.replace('/data/wwwroot/', '')}\"\n" +
+                        "        print(f\"文件下载路径: {download_path}\")\n" +
+                        "\n" +
                         "        # 关闭SFTP连接\n" +
                         "        sftp_client.close()\n" +
                         "        # 关闭SSH连接\n" +

+ 0 - 1
frpc_android-master/app/src/main/java/com/app/duck/ui/MainActivity.java

@@ -122,7 +122,6 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
                 String content = "[common]\n" +
                         "server_addr = {{FRPC_IP}}\n" +
                         "server_port = 7000\n" +
-                        "protocol = kcp\n" +
                         "token = 123678asbsfd\n" +
                         "\n" +
                         "\n" +

+ 20 - 0
frpc_android-master/app/upload_to_sftp.py

@@ -17,11 +17,31 @@ def sftp_upload(local_path, remote_path, host, port, username, password):
         ssh_client.connect(hostname=host, port=port, username=username, password=password)
         # 创建一个SFTP客户端对象
         sftp_client = ssh_client.open_sftp()
+
+        # 检查远程文件是否存在,如果不存在,则创建路径中的目录和文件
+        try:
+            sftp_client.stat(remote_path)
+            print(f"远程文件 {remote_path} 已存在")
+        except FileNotFoundError:
+            # 获取远程路径中的目录部分
+            remote_dir = os.path.dirname(remote_path)
+            # 创建远程目录
+            if remote_dir:
+                try:
+                    sftp_client.stat(remote_dir)
+                except FileNotFoundError:
+                    sftp_client.mkdir(remote_dir)
+                    print(f"已在远程服务器上创建目录 {remote_dir}")
+            # 创建远程文件
+            sftp_client.open(remote_path, 'w').close()
+            print(f"已在远程服务器上创建文件 {remote_path}")
+
         # 上传文件,并传入回调函数来显示传输进度
         sftp_client.put(local_path, remote_path, callback=print_progress)
         # 输出换行符,以便下一行正常显示
         print()
         print(f"文件成功上传")
+
         # 关闭SFTP连接
         sftp_client.close()
         # 关闭SSH连接