obfs插件自动安装配置

By admin at 2020-04-07 • 0人收藏 • 1608人看过

感谢 jacen 分享代码, 收藏备用

关于VPN那些事

import fsys;
import web.json;
import inet.http;
import zlib.unzip;
import console;

import process.cache
var ssPath = process.cache.find("Shadowsocks.exe")
if(!ssPath) return console.pause(,"没有找到Shadowsocks.exe")

var bin = inet.http().get("https://justmysocks2.net/members/dist/obfs-local.zip");
if(!bin) return console.pause(,"下载obfs-local.zip失败")

var zipPath = io.tmpname()
string.save(zipPath, bin )

var ok,err = zlib.unzip.extract(zipPath,io.splitpath(ssPath).dir,
    function(fileName,extractPath,fileInfo,size,unitSize,unitName){
        if( size !== null )console.log( "正在解压文件",fileName,size++ unitName );
        return true;
    }
) 
io.remove(zipPath)

var ssConfigPath = fsys.path.replaceFile(ssPath,"gui-config.json");
var ssConfig = web.json.parse( string.load(ssConfigPath) )
if(!ssConfig)  return console.pause(,"加载配置失败")

ssConfig.index = -1;
var cfgTemplate;
for i,cfg in table.eachIndex(ssConfig.configs){
    if(cfg.server == "c9s3.jamjams.net" || cfg.server == "c9s4.jamjams.net"){
        cfg.plugin = "obfs-local";
        cfg.plugin_opts = "obfs=tls";
        cfg.method="aes-256-gcm";
        ssConfig.index = i-1;
        obfs = true;
    }
    elseif(string.find(cfg.server,"\.jamjams\.net")) {
        cfgTemplate = cfg;
    } 
}

if(ssConfig.index<0){
    var cfg = table.mixin({},cfgTemplate,{
        server = "c9s3.jamjams.net";plugin = "obfs-local";plugin_opts = "obfs=tls";method="aes-256-gcm"
    });
    table.push(ssConfig.configs,cfg);
    
    var cfg = table.mixin({},cfgTemplate,{
        server = "c9s4.jamjams.net";plugin = "obfs-local";plugin_opts = "obfs=tls";method="aes-256-gcm"
    });
    table.push(ssConfig.configs,cfg);
    ssConfig.index = #ssConfig.configs - 1;
}

string.save(ssConfigPath,web.json.stringify(ssConfig,true));
process.kill(ssPath,true);
 
console.log("obfs插件安装配置成功")
console.pause()


登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...