private void RunTrojan() { if (IsConfigValid()) { InitialTemp(); try { File.WriteAllText("node.tcsdb", ShareLink.Generate(RemoteAddressBox.Text, RemotePortBox.Text, PasswordBox.Text)); } catch { Message.Show("Conf file written failed!", Message.Mode.Error); goto final; } KillProcess(); SaveTrojanConf(); RunTrojanCommand(); if (isHttp.Checked == true) { RunPivoxyCommand(); Proxy.SetProxy("127.0.0.1:54392"); } Message.Show("Stop Trojan succeeded!", Message.Mode.Info); final :; } else { Message.Show("Config invalid! Please enter current trojan information.", Message.Mode.Error); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(ShareLink model, SqlTransaction tran = null) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ShareLink set "); strSql.Append("UserID=@UserID,ShareOpenId=@ShareOpenId,ShareToken=@ShareToken,ShareMd5Key=@ShareMd5Key,ShareAddress=@ShareAddress"); strSql.Append(" where ShareLinkID=@ShareLinkID"); SqlParameter[] parameters = { new SqlParameter("@UserID", model.UserID), new SqlParameter("@ShareOpenId", model.ShareOpenId), new SqlParameter("@ShareToken", model.ShareToken), new SqlParameter("@ShareMd5Key", model.ShareMd5Key), new SqlParameter("@ShareAddress", model.ShareAddress), new SqlParameter("@ShareLinkID", model.ShareLinkID) }; if (tran == null) { return(SqlHelper.ExecuteSql(strSql.ToString(), CommandType.Text, parameters) > 0); } else { return(SqlHelper.ExecuteSql(tran, CommandType.Text, strSql.ToString(), parameters) > 0); } }
public string GetShareLink(Server s) { if (Global.Settings.V2RayConfig.V2rayNShareLink) { var server = (VMess)s; var vmessJson = JsonSerializer.Serialize(new V2rayNSharing { v = 2, ps = server.Remark, add = server.Hostname, port = server.Port, id = server.UserID, aid = server.AlterID, net = server.TransferProtocol, type = server.FakeType, host = server.Host, path = server.Path, tls = server.TLSSecureType }, new JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }); return("vmess://" + ShareLink.URLSafeBase64Encode(vmessJson)); } return(V2rayUtils.GetVShareLink(s)); }
public string GetShareLink() { if (Type == ProjectType.Xray) { StringBuilder strBuilder = new StringBuilder(); XraySettings.Types.ForEach(type => { var link = ShareLink.Build(type, XraySettings); strBuilder.AppendLine(link); }); return(strBuilder.ToString()); } if (Type == ProjectType.TrojanGo) { return(ShareLink.BuildTrojanGo(TrojanGoSettings)); } if (Type == ProjectType.NaiveProxy) { return(ShareLink.BuildNaiveProxy(NaiveProxySettings)); } return(string.Empty); }
private void CopyLinkPictureBox_Click(object sender, EventArgs e) { // 当前ServerComboBox中至少有一项 if (ServerComboBox.SelectedIndex == -1) { MessageBoxX.Show(i18N.Translate("Please select a server first")); return; } try { //听说巨硬BUG经常会炸,所以Catch一下 :D var server = (Server)ServerComboBox.SelectedItem; string text; if (ModifierKeys == Keys.Control) { text = ShareLink.GetNetchLink(server); } else { text = ShareLink.GetShareLink(server); } Clipboard.SetText(text); } catch (Exception) { // ignored } }
public void TestServerFromSSR() { const string normalCase = "ssr://MTI3LjAuMC4xOjEyMzQ6YXV0aF9hZXMxMjhfbWQ1OmFlcy0xMjgtY2ZiOnRsczEuMl90aWNrZXRfYXV0aDpZV0ZoWW1KaS8_b2Jmc3BhcmFtPVluSmxZV3QzWVRFeExtMXZaUQ"; var server = (ShadowsocksR)ShareLink.ParseText(normalCase).First(); Assert.AreEqual(server.Hostname, "127.0.0.1"); Assert.AreEqual(server.Port, (ushort)1234); Assert.AreEqual(server.Protocol, "auth_aes128_md5"); Assert.AreEqual(server.EncryptMethod, "aes-128-cfb"); Assert.AreEqual(server.OBFS, "tls1.2_ticket_auth"); Assert.AreEqual(server.OBFSParam, "breakwa11.moe"); Assert.AreEqual(server.Password, "aaabbb"); const string normalCaseWithRemark = "ssr://MTI3LjAuMC4xOjEyMzQ6YXV0aF9hZXMxMjhfbWQ1OmFlcy0xMjgtY2ZiOnRsczEuMl90aWNrZXRfYXV0aDpZV0ZoWW1KaS8_b2Jmc3BhcmFtPVluSmxZV3QzWVRFeExtMXZaUSZyZW1hcmtzPTVyV0w2Sy1WNUxpdDVwYUg"; server = (ShadowsocksR)ShareLink.ParseText(normalCaseWithRemark).First(); Assert.AreEqual(server.Hostname, "127.0.0.1"); Assert.AreEqual(server.Port, (ushort)1234); Assert.AreEqual(server.Protocol, "auth_aes128_md5"); Assert.AreEqual(server.EncryptMethod, "aes-128-cfb"); Assert.AreEqual(server.OBFS, "tls1.2_ticket_auth"); Assert.AreEqual(server.OBFSParam, "breakwa11.moe"); Assert.AreEqual(server.Password, "aaabbb"); Assert.AreEqual(server.Remark, "测试中文"); }
public string GetShareLink(Server s) { var server = (Shadowsocks)s; // ss://method:password@server:port#Remark return("ss://" + ShareLink.URLSafeBase64Encode($"{server.EncryptMethod}:{server.Password}@{server.Hostname}:{server.Port}") + "#" + HttpUtility.UrlEncode(server.Remark)); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Add(ShareLink model, SqlTransaction tran = null) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ShareLink("); strSql.Append(" UserID,ShareOpenId,ShareToken,ShareMd5Key,ShareAddress )"); strSql.Append(" values ("); strSql.Append("@UserID,@ShareOpenId,@ShareToken,@ShareMd5Key,@ShareAddress)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserID", model.UserID), new SqlParameter("@ShareOpenId", model.ShareOpenId), new SqlParameter("@ShareToken", model.ShareToken), new SqlParameter("@ShareMd5Key", model.ShareMd5Key), new SqlParameter("@ShareAddress", model.ShareAddress), }; object obj; if (tran == null) { obj = SqlHelper.GetSingle(strSql.ToString(), CommandType.Text, parameters); } else { obj = SqlHelper.GetSingle(tran, CommandType.Text, strSql.ToString(), parameters); } return(obj == null ? 0 : Convert.ToInt32(obj)); }
public enErrorCode EditShareLink(EditShareLinkRequestDTO dto) { enErrorCode enCode = enErrorCode.EXCEPTION; try { ShareLink sl = _dbContext.Set <ShareLink>().Find(dto.LID); sl.Category = dto.Category.ToString(); sl.Title = (String.IsNullOrEmpty(dto.Title)) ? String.Empty : dto.Title; sl.Description = (String.IsNullOrEmpty(dto.Description)) ? String.Empty : dto.Description; sl.ImgUrl = (String.IsNullOrEmpty(dto.ImgUrl)) ? String.Empty : dto.ImgUrl; sl.LinkUrl = (String.IsNullOrEmpty(dto.LinkUrl)) ? String.Empty : dto.LinkUrl; int result = _dbContext.SaveChanges(); if (result == 1) { enCode = enErrorCode.SUCCESS; } } catch (Exception ex) { throw; } return(enCode); }
public enErrorCode AddShareLink(AddShareLinkRequestDTO dto) { enErrorCode enCode = enErrorCode.EXCEPTION; try { ShareLink sl = new ShareLink() { Category = dto.Category.ToString(), Title = (String.IsNullOrEmpty(dto.Title)) ? String.Empty : dto.Title, Description = (String.IsNullOrEmpty(dto.Description)) ? String.Empty : dto.Description, ImgUrl = (String.IsNullOrEmpty(dto.ImgUrl)) ? "/" : dto.ImgUrl, LinkUrl = (String.IsNullOrEmpty(dto.LinkUrl)) ? "http://" : dto.LinkUrl }; var dbSet = _dbContext.Set <ShareLink>().Add(sl); int result = _dbContext.SaveChanges(); if (result == 1) { enCode = enErrorCode.SUCCESS; } } catch (Exception ex) { throw; } return(enCode); }
private void TCS_Load(object sender, EventArgs e) { InitialTemp(); if (File.Exists("config.ini")) { IniData iniData = iniParser.ReadFile("config.ini"); try { localPort = int.Parse(iniData["TCS"]["LocalPort"]); } catch { iniData["TCS"]["LocalPort"] = "1080"; iniParser.WriteFile("config.ini", iniData); localPort = 1080; } ConfigIniToCheckBox("TCS", "VerifyCert", isVerifyCert, "True"); ConfigIniToCheckBox("TCS", "VerifyHostname", isVerifyHostname, "True"); ConfigIniToCheckBox("TCS", "HttpProxy", isHttp, "True"); } else { File.WriteAllText("config.ini", "" + "[TCS]\r\n" + "LocalPort = 1080\r\n" + "VerifyCert = True\r\n" + "VerifyHostname = True\r\n" + "HttpProxy = True"); isVerifyCert.Checked = true; isVerifyHostname.Checked = true; } if (IsPortUsed(localPort)) { Message.Show($"Port {localPort} is in use!\r\nTrojan may fail to work.", Message.Mode.Warning); } if (IsPortUsed(54392)) { Message.Show("Port 54392 is in use!\r\nTrojan may fail to work.", Message.Mode.Warning); } if (File.Exists("node.tcsdb")) { string[] tmp = ShareLink.ConvertShareToTrojanConf(File.ReadAllText("node.tcsdb")); if (!SetTrojanConf(File.ReadAllText("node.tcsdb"))) { File.Create("node.tcsdb").Dispose(); } } else { File.Create("node.tcsdb").Dispose(); } #if DEBUG this.Text = "[D]" + this.Text; #endif }
public string GetShareLink(Server s) { var server = (ShadowsocksR)s; // https://github.com/shadowsocksr-backup/shadowsocks-rss/wiki/SSR-QRcode-scheme // ssr://base64(host:port:protocol:method:obfs:base64pass/?obfsparam=base64param&protoparam=base64param&remarks=base64remarks&group=base64group&udpport=0&uot=0) var paraStr = $"/?obfsparam={ShareLink.URLSafeBase64Encode(server.OBFSParam)}&protoparam={ShareLink.URLSafeBase64Encode(server.ProtocolParam)}&remarks={ShareLink.URLSafeBase64Encode(server.Remark)}"; return("ssr://" + ShareLink.URLSafeBase64Encode($"{server.Hostname}:{server.Port}:{server.Protocol}:{server.EncryptMethod}:{server.OBFS}:{ShareLink.URLSafeBase64Encode(server.Password)}{paraStr}")); }
/// <summary> /// 修改 (可能有其他业务逻辑检查) /// </summary> /// <param name="model"></param> /// <returns></returns> public ResultInfo Update(ShareLink model, SqlTransaction tran = null) { ResultInfo ri = new ResultInfo(); if (Edit(model, tran)) { ri.Ok = true; ri.Msg = "修改成功"; } return(ri); }
private void ImportServersFromClipboardToolStripMenuItem_Click(object sender, EventArgs e) { var texts = Clipboard.GetText(); if (!string.IsNullOrWhiteSpace(texts)) { Global.Settings.Server.AddRange(ShareLink.ParseText(texts)); NotifyTip(i18N.TranslateFormat("Import {0} server(s) form Clipboard", ShareLink.ParseText(texts).Count)); InitServer(); Configuration.Save(); } }
public void DisableToSocialNetworkSharing() { if (ShareFB.Selected) { ShareFB.Click(); } if (ShareTwitter.Selected) { ShareTwitter.Click(); } if (ShareLink.Selected) { ShareLink.Click(); } }
public async Task <SharedLinkResponse> GetShareLink(string projectId, int fileProjectId) { var shareLink = new ShareLink() { ProjectFileID = fileProjectId }; var json = JsonConvert.SerializeObject(shareLink); var sharedLinkUrl = $"https://studioapi.bluebeam.com/publicapi/v1/projects/{projectId}/sharedlinks"; var client = new HttpAuthClient(); var response = await client.Post(sharedLinkUrl, json, User, _userManager); var sharedLinkResponse = JsonConvert.DeserializeObject <SharedLinkResponse>(response); return(sharedLinkResponse); }
public IEnumerable <Server> ParseSsdUri(string s) { var json = JsonConvert.DeserializeObject <Main>(ShareLink.URLSafeBase64Decode(s.Substring(6))); return(json.servers.Select(server => new Shadowsocks { Remark = server.remarks, Hostname = server.server, Port = server.port != 0 ? server.port : json.port, Password = server.password ?? json.password, EncryptMethod = server.encryption ?? json.encryption, Plugin = string.IsNullOrEmpty(json.plugin) ? string.IsNullOrEmpty(server.plugin) ? null : server.plugin : json.plugin, PluginOption = string.IsNullOrEmpty(json.plugin_options) ? string.IsNullOrEmpty(server.plugin_options) ? null : server.plugin_options : json.plugin_options }) .Where(CheckServer)); }
private void ExportXraySettings(object sender, RoutedEventArgs e) { StringBuilder sb = new StringBuilder(); foreach (var record in Records.Where(x => x.IsChecked)) { record.Settings.Types.ForEach(type => { var link = ShareLink.Build(type, record.Settings); sb.AppendLine(link); }); } var tbx = new TextBoxWindow("分享链接", sb.ToString()); tbx.ShowDialog(); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); string s; try { s = ShareLink.URLSafeBase64Decode(text.Substring(8)); } catch { return(V2rayUtils.ParseVUri(text)); } V2rayNSharing vmess = JsonSerializer.Deserialize <V2rayNSharing>(s, new JsonSerializerOptions { NumberHandling = JsonNumberHandling.WriteAsString | JsonNumberHandling.AllowReadingFromString }) !; data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = vmess.port; data.UserID = vmess.id; data.AlterID = vmess.aid; data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host !)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecureType = vmess.tls; data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(new[] { data }); }
public void ParseV2RayNFormatUri() { var server = (VMess)ShareLink.ParseText( @"vmess://eyAidiI6ICIyIiwgInBzIjogIuWkh+azqOWIq+WQjSIsICJhZGQiOiAiMTExLjExMS4xMTEuMTExIiwgInBvcnQiOiAiMzIwMDAiLCAiaWQiOiAiMTM4NmY4NWUtNjU3Yi00ZDZlLTlkNTYtNzhiYWRiNzVlMWZkIiwgImFpZCI6ICIxMDAiLCAibmV0IjogInRjcCIsICJ0eXBlIjogIm5vbmUiLCAiaG9zdCI6ICJ3d3cuYmJiLmNvbSIsICJwYXRoIjogIi8iLCAidGxzIjogInRscyIgfQ==") .First(); Assert.AreEqual(server.Remark, "备注别名"); Assert.AreEqual(server.Hostname, "111.111.111.111"); Assert.AreEqual(server.Port, (ushort)32000); Assert.AreEqual(server.UserID, "1386f85e-657b-4d6e-9d56-78badb75e1fd"); Assert.AreEqual(server.AlterID, 100); Assert.AreEqual(server.TransferProtocol, "tcp"); Assert.AreEqual(server.FakeType, "none"); Assert.AreEqual(server.Host, "www.bbb.com"); Assert.AreEqual(server.Path, "/"); Assert.AreEqual(server.TLSSecureType, "tls"); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMessServer(); string s; try { s = ShareLink.URLSafeBase64Decode(text.Substring(8)); } catch { return(V2rayUtils.ParseVUri(text)); } V2rayNJObject vmess = JsonSerializer.Deserialize <V2rayNJObject>(s, new JsonSerializerOptions { NumberHandling = JsonNumberHandling.WriteAsString | JsonNumberHandling.AllowReadingFromString }) !; data.Remark = vmess.ps; data.Hostname = vmess.add; data.EncryptMethod = vmess.scy; data.Port = vmess.port; data.UserID = vmess.id; data.AlterID = vmess.aid; data.TransferProtocol = vmess.net; data.FakeType = vmess.type; data.ServerName = vmess.sni; if (data.TransferProtocol == "quic") { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecureType = vmess.tls; return(new[] { data }); }
/// <summary> /// 取得 企業會員詳細資料 /// </summary> /// <param name="CID">公司代碼</param> /// <returns></returns> public GetLinkDetailReturnDTO GetLinkDetail(int LID) { GetLinkDetailReturnDTO returnDto = null; ShareLink sl = _dbContext.Set <ShareLink>().Find(LID); returnDto = new GetLinkDetailReturnDTO() { LID = sl.LID, Category = (enLinkCategory)Enum.Parse(typeof(enLinkCategory), sl.Category), Title = sl.Title, Description = sl.Description, ImgUrl = sl.ImgUrl, LinkUrl = sl.LinkUrl }; return(returnDto); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); text = text.Substring(8); V2rayNSharing vmess; try { vmess = JsonConvert.DeserializeObject <V2rayNSharing>(ShareLink.URLSafeBase64Decode(text)); } catch (Exception e) { Logging.Warning(e.ToString()); return(null); } data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = ushort.Parse(vmess.port); data.UserID = vmess.id; data.AlterID = int.Parse(vmess.aid); data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecure = vmess.tls == "tls"; data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(CheckServer(data) ? new[] { data } : null); }
/// <summary> /// 保存 (可能有其他业务逻辑检查) /// </summary> /// <param name="model">实体</param> /// <returns></returns> public ResultInfo Create(ShareLink model, SqlTransaction tran = null) { ResultInfo ri = new ResultInfo(); if (model == null) { return(ri); } int result = Add(model, tran); if (result > 0) { ri.Ok = true; ri.Msg = "添加成功"; } return(ri); }
public IEnumerable <Server> ParseUri(string text) { var data = new VMess(); V2rayNSharing vmess; try { vmess = JsonSerializer.Deserialize <V2rayNSharing>(ShareLink.URLSafeBase64Decode(text.Substring(8))); } catch { return(V2rayUtils.ParseVUri(text)); } data.Remark = vmess.ps; data.Hostname = vmess.add; data.Port = ushort.Parse(vmess.port); data.UserID = vmess.id; data.AlterID = int.Parse(vmess.aid); data.TransferProtocol = vmess.net; data.FakeType = vmess.type; if (data.TransferProtocol == "quic") { if (VMessGlobal.QUIC.Contains(vmess.host)) { data.QUICSecure = vmess.host; data.QUICSecret = vmess.path; } } else { data.Host = vmess.host; data.Path = vmess.path; } data.TLSSecureType = vmess.tls; data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个 return(new[] { data }); }
private void CopyLinkPictureBox_Click(object sender, EventArgs e) { // 当前ServerComboBox中至少有一项 if (ServerComboBox.SelectedIndex != -1) { var selectedMode = (Models.Server)ServerComboBox.SelectedItem; try { //听说巨硬BUG经常会炸,所以Catch一下 :D Clipboard.SetText(ShareLink.GetShareLink(selectedMode)); } catch (Exception) { } } else { MessageBoxX.Show(i18N.Translate("Please select a server first")); } }
private void ImportServersFromClipboardToolStripMenuItem_Click(object sender, EventArgs e) { var texts = Clipboard.GetText(); if (!string.IsNullOrWhiteSpace(texts)) { var result = ShareLink.Parse(texts); if (result != null) { Global.Settings.Server.AddRange(result); } else { MessageBoxX.Show(i18N.Translate("Import servers error!"), info: false); } InitServer(); Configuration.Save(); } }
public string GetShareLink(Server s) { var server = (VMess)s; var vmessJson = JsonConvert.SerializeObject(new { v = "2", ps = server.Remark, add = server.Hostname, port = server.Port, id = server.UserID, aid = server.AlterID, net = server.TransferProtocol, type = server.FakeType, host = server.Host, path = server.Path, tls = server.TLSSecure ? "tls" : "" }); return("vmess://" + ShareLink.URLSafeBase64Encode(vmessJson)); }
public void ParseVLESSUri() { var servers = ShareLink.ParseText(@"vmess://[email protected]:31415?encryption=none#VMessTCPNaked vmess://[email protected]:9265#VMessTCPAuto vmess://[email protected]:35897?encryption=aes-128-gcm#VMessTCPAES vmess://[email protected]:9323?encryption=none&security=tls#VMessTCPTLSNaked vmess://[email protected]:8462?security=tls#VMessTCPTLS vmess://[email protected]:64338?encryption=none&security=tls&sni=fastgit.org#VMessTCPTLSSNI vless://[email protected]:3279?security=xtls&flow=rprx-xtls-splice#VLESSTCPXTLSSplice vless://[email protected]:50288?type=kcp&seed=69f04be3-d64e-45a3-8550-af3172c63055#VLESSmKCPSeed vless://[email protected]:41971?type=kcp&headerType=wireguard&seed=69f04be3-d64e-45a3-8550-af3172c63055#VLESSmKCPSeedWG vmess://[email protected]:6939?type=ws&security=tls&host=qv2ray.net&path=%2Fsomewhere#VMessWebSocketTLS"); foreach (var server in servers) { var jsonSerializerOptions = Global.NewDefaultJsonSerializerOptions; jsonSerializerOptions.WriteIndented = false; Console.WriteLine(JsonSerializer.Serialize <object>(server, jsonSerializerOptions) + "\n"); Assert.IsNotNull(server); Assert.AreEqual(server.Hostname, "qv2ray.net"); } }
private void ImportServersFromClipboardToolStripMenuItem_Click(object sender, EventArgs e) { var texts = Clipboard.GetText(); if (!string.IsNullOrWhiteSpace(texts)) { var result = ShareLink.Parse(texts); if (result != null) { foreach (var server in result) { Global.Settings.Server.Add(server); } } else { MessageBoxX.Show(i18N.Translate("Import servers error!"), LogLevel.ERROR); } Configuration.Save(); } }