强子新街口
This commit is contained in:
627
Services/Hncore.Pass.Vpn/Service/AgentClient10Service.cs
Normal file
627
Services/Hncore.Pass.Vpn/Service/AgentClient10Service.cs
Normal file
@@ -0,0 +1,627 @@
|
||||
using AngleSharp.Html.Parser;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Serializer;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class AgentClient10Service:AgentClientBaseService
|
||||
{
|
||||
string LoginUrl { get; set; } = "api/login";
|
||||
string LoginCodeUrl { get; set; } = "main/imgcode.html";
|
||||
string RefrushTokenUrl { get; set; } = "agent/index.html";
|
||||
string SingleAddUrl { get; set; } = "api/number";
|
||||
string SingleReAddUrl { get; set; } = "api/number/renew";
|
||||
string MuiltAddUrl { get; set; } = "agent/memberMuiltAdd.html";
|
||||
string RefundUrl { get; set; } = "api/number/refund";
|
||||
string UpdateUrl = "api/number/";//agent/memberUpdate/id/1155709.html
|
||||
string OnlineUrl { get; set; } = "api/numberLine/";
|
||||
string KIllUrl { get; set; } = "api/numberOffline";
|
||||
string searchAccountUrl = "api/numberSingle/";
|
||||
string searchTestAccountUrl = "api/numberSingle/";
|
||||
string DeleteUrl { get; set; } = "api/number/refund";//1160862.html";
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
public AgentClient10Service(IHttpClientFactory httpClientFactory):base(httpClientFactory)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public override async Task<int> RefrushStatus()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public override async Task<(byte[], string)> GetCode()
|
||||
{
|
||||
var client = CreateHttpClient(false);
|
||||
if (this.LoginUrl.NotHas()) return (null, "");
|
||||
var getResp = await client.GetAsync(this.LoginUrl);
|
||||
var cookie = this.GetCookie(getResp, "PHPSESSID");
|
||||
if (cookie.Has())
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("Cookie", cookie);
|
||||
var ret = await client.GetByteArrayAsync(this.LoginCodeUrl + "?t=" + DateTime.Now.Millisecond);
|
||||
return (ret, cookie);
|
||||
}
|
||||
return (null, "");
|
||||
}
|
||||
public override async Task<ApiResult> Login(AgentLoginRequest request)
|
||||
{
|
||||
return new ApiResult(request.Key);
|
||||
}
|
||||
public override bool CheckAccount(int productId,List<string> accounts)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int payCount = 1)
|
||||
{
|
||||
|
||||
var time_s = DateTime.Now.GetUnixTimeStamp();
|
||||
var agentid = "";
|
||||
var nonce = "";
|
||||
var apikey = "";
|
||||
var sign = MD5(time_s+nonce+apikey);
|
||||
var url = "/api/raduserCreate?agentid="+agentid+"&ti="+time_s+"&nonce="+nonce+"&sign="+sign+"&username="+account+"&password="+pwd+"&prdi=**&maxonline="+connCount+"&day=**";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["errcode"].ToString();
|
||||
if (status =="0")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
|
||||
|
||||
// var client = CreateHttpClient();
|
||||
// var interval = "1";
|
||||
// if(packageKey == "2"){
|
||||
// interval ="2";
|
||||
// packageKey = "month";
|
||||
// } else if(packageKey == "3") {
|
||||
// interval ="3";
|
||||
// packageKey = "month";
|
||||
// }
|
||||
// var map = new Dictionary<string, string>(){
|
||||
// {"group","single" },
|
||||
// {"number",account },
|
||||
// {"password",pwd },
|
||||
// {"connect",connCount.ToString()},
|
||||
// {"interval",interval},
|
||||
// {"type",packageKey},
|
||||
// {"body","api"},
|
||||
// {"mobile","13073735878"}
|
||||
// };
|
||||
// var title = GetOpTitle("NewAccount", account);
|
||||
// LogHelper.Info(title, map.ToJson());
|
||||
// try
|
||||
// {
|
||||
// var resp = await client.PostAsForm(this.SingleAddUrl, map);
|
||||
// var content = await resp.Content.ReadAsStringAsync();
|
||||
// JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
// var status = jo["status"].ToString();
|
||||
// if (status =="400")
|
||||
// {
|
||||
// return new ApiResult(ResultCode.C_SUCCESS);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LogHelper.Error(title, content);
|
||||
// return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// LogHelper.Error(title, ex.Message);
|
||||
// return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewMuiltAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1,int startNum=0, int endNum=1 )
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"group","single" },
|
||||
{"number",account },
|
||||
{"password",pwd },
|
||||
{"connect",connCount.ToString()},
|
||||
{"interval","1"},
|
||||
{"type",packageKey},
|
||||
{"body","api"},
|
||||
{"mobile","13073735878"}
|
||||
};
|
||||
var title = GetOpTitle("NewAccount", account);
|
||||
LogHelper.Info(title, map.ToJson());
|
||||
try
|
||||
{
|
||||
var resp = await client.PostAsForm(this.SingleAddUrl, map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["status"].ToString();
|
||||
if (status =="400")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewReAccount(string packageKey, string account, int connCount, int payCount = 1)
|
||||
{
|
||||
|
||||
var time_s = DateTime.Now.GetUnixTimeStamp();
|
||||
var agentid = "";
|
||||
var nonce = "";
|
||||
var apikey = "";
|
||||
var sign = MD5(time_s+nonce+apikey);
|
||||
var url = "/api/raduserRenew?agentid="+agentid+"&ti="+time_s+"&nonce="+nonce+"&sign="+sign+"&username="+account+"&day=**";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["errcode"].ToString();
|
||||
if (status =="0")
|
||||
{
|
||||
return new ApiResult(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// var client = CreateHttpClient();
|
||||
|
||||
// var infoRet = await this.GetAccountInfo(account);
|
||||
// var id = infoRet.Data.Id;
|
||||
|
||||
// var map = new Dictionary<string, string>(){
|
||||
// {"type",packageKey },
|
||||
// {"ids[]",id },
|
||||
// {"interval","1" },
|
||||
// };
|
||||
// var title = GetOpTitle("NewReAccount", account);
|
||||
// LogHelper.Info(title, map.ToJson());
|
||||
// try
|
||||
// {
|
||||
// var resp = await client.PostAsForm(this.SingleReAddUrl, map);
|
||||
// var content = await resp.Content.ReadAsStringAsync();
|
||||
// JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
// var status = jo["status"].ToString();
|
||||
// if (status =="400")
|
||||
// {
|
||||
// return new ApiResult(1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LogHelper.Error(title, content);
|
||||
// return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// LogHelper.Error(title, ex.Message);
|
||||
// return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
// }
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> DeleteAccount(string account)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var infoRet = await this.GetAccountInfo(account, true);
|
||||
if (infoRet.Code != ResultCode.C_SUCCESS)
|
||||
return false;
|
||||
|
||||
var title = GetOpTitle("DeleteAccount", account);
|
||||
LogHelper.Info(title, account);
|
||||
try
|
||||
{
|
||||
var delete = this.DeleteUrl + infoRet.Data.Id + ".html";
|
||||
var resp = await client.GetAsync(delete);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("alert(\"删除成功\")") != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到账号信息
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<OriginAccountModel>> GetAccountInfo(string account,bool isTest=false)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("GetAccountInfo", account);
|
||||
|
||||
var info = "";
|
||||
try
|
||||
{
|
||||
var url = this.searchAccountUrl + account;
|
||||
if (isTest)
|
||||
{
|
||||
url = this.searchTestAccountUrl + account;
|
||||
}
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var data = jo["data"];
|
||||
|
||||
var trData = new OriginAccountModel
|
||||
{
|
||||
Id = data["id"].ToString(),
|
||||
Account = data["number"].ToString(),
|
||||
Pwd = data["password"].ToString(),
|
||||
AccountType = data["status"].ToBool()?"未到期":"已到期",
|
||||
Package = "",
|
||||
ConnectCount = data["connect"].ToString(),
|
||||
RegistTime = data["add_time"].ToString(),
|
||||
EndTime = data["end_time"].ToString(),
|
||||
RestTime = "",
|
||||
Amount = data["balance"].ToString(),
|
||||
Remark = data["body"].ToString(),
|
||||
};
|
||||
return new ApiResult<OriginAccountModel>(trData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message+"-->info:"+ info);
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_INVALID_ERROR, "查询失败");
|
||||
}
|
||||
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_INVALID_ERROR, "没有查询到信息");
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> UpdateAccountPwd(string account, string pwd)
|
||||
{
|
||||
|
||||
|
||||
var time_s = DateTime.Now.GetUnixTimeStamp();
|
||||
var agentid = "";
|
||||
var nonce = "";
|
||||
var apikey = "";
|
||||
var sign = MD5(time_s+nonce+apikey);
|
||||
var url = "/api/raduserChpw?agentid="+agentid+"&ti="+time_s+"&nonce="+nonce+"&sign="+sign+"&username="+account+"&newpass="+pwd;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["errcode"].ToString();
|
||||
if (status =="0")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// var ret = await this.GetAccountInfo(account);
|
||||
// if (ret.Code != ResultCode.C_SUCCESS)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// var accountModel = ret.Data;
|
||||
// if (accountModel == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// var client = CreateHttpClient();
|
||||
// var map = new Dictionary<string, string>(){
|
||||
// {"number",account },
|
||||
// {"password",pwd },
|
||||
// {"body","修改密码"+account },
|
||||
// };
|
||||
// LogHelper.Info(GetOpTitle("UpdateAccountPwd", account), map.ToJson());
|
||||
// try
|
||||
// {
|
||||
// var resp = await client.PostAsForm(this.UpdateUrl, map);
|
||||
// var content = await resp.Content.ReadAsStringAsync();
|
||||
|
||||
// JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
// var status = jo["status"].ToString();
|
||||
// if (status =="400")
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LogHelper.Error(GetOpTitle("UpdateAccountPwd", account), content);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// LogHelper.Error(GetOpTitle("UpdateAccountPwd", account), ex);
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> Refund(string account, string packageKey, int days)
|
||||
{
|
||||
|
||||
var infoRet = await this.GetAccountInfo(account);
|
||||
// Console.WriteLine(infoRet.ToJson());
|
||||
// await Task.Delay(50);
|
||||
var id = infoRet.Data.Id;
|
||||
|
||||
//{"DefaultRequestHeaders":[{"Key":"hl","Value":["hl"]},{"Key":"Cookie","Value":["EtV1DHm0lJwaH9n4dhKUOIGSO8XKroVSRY7shrgFTJyzk3hANqLsVoiYAIzDR8M7"]},{"Key":"Authorization","Value":["Bearer EtV1DHm0lJwaH9n4dhKUOIGSO8XKroVSRY7shrgFTJyzk3hANqLsVoiYAIzDR8M7"]}],"BaseAddress":"http://xjip.hlapi.com/","Timeout":"00:01:40","MaxResponseContentBufferSize":2147483647}
|
||||
// var client = CreateHttpClient();
|
||||
// var get_token = client.DefaultRequestHeaders.GetCookies()[0].Cookies[0].Name;
|
||||
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://xjip.hlapi.com/api/number/refund");
|
||||
|
||||
req.Method = "DELETE";
|
||||
|
||||
req.ContentType = "application/x-www-form-urlencoded";
|
||||
req.Headers.Add("Authorization", "Bearer w1v9MjG58z6qEzKPUVAdyhRBM8h1vYZVAGc4YpGx525APv9YHQPKuxVMt5EpF87A");
|
||||
|
||||
req.Timeout = 30000;//请求超时时间
|
||||
|
||||
|
||||
|
||||
var postData = "id=" + id;
|
||||
|
||||
byte[] data = Encoding.UTF8.GetBytes(postData);
|
||||
|
||||
req.ContentLength = data.Length;
|
||||
|
||||
|
||||
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
|
||||
reqStream.Close();
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine(postData);
|
||||
|
||||
|
||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
|
||||
Stream stream = resp.GetResponseStream();
|
||||
|
||||
string result = "";
|
||||
//获取响应内容
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
result = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
return new ApiResult(1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// var client = CreateHttpClient();
|
||||
|
||||
|
||||
// // client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
|
||||
|
||||
// var infoRet = await this.GetAccountInfo(account);
|
||||
// var id = infoRet.Data.Id;
|
||||
|
||||
// var map = new Dictionary<string, string>(){
|
||||
// {"id",id },
|
||||
// };
|
||||
// var title = GetOpTitle("Refund", account);
|
||||
// LogHelper.Info(title, map.ToJson());
|
||||
// try
|
||||
// {
|
||||
// var resp = await client.DeleteAsForm(this.RefundUrl, map);
|
||||
// var content = await resp.Content.ReadAsStringAsync();
|
||||
// content = System.Text.RegularExpressions.Regex.Unescape(content);
|
||||
|
||||
// JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
// var status = jo["status"].ToString();
|
||||
// if (status =="400")
|
||||
// {
|
||||
// return new ApiResult(1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LogHelper.Error(title, content);
|
||||
// return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// LogHelper.Error(title, ex.Message);
|
||||
// return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
// }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(string account)
|
||||
{
|
||||
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("OnLine", account);
|
||||
|
||||
var info = "";
|
||||
try
|
||||
{
|
||||
var url = this.OnlineUrl + account;
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
content = content.Replace("[","");
|
||||
content = content.Replace("]","");
|
||||
|
||||
|
||||
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
|
||||
var retData = new List<OriginAccountOnlineModel>();
|
||||
var jsondata = jo;
|
||||
|
||||
|
||||
var trData = new OriginAccountOnlineModel
|
||||
{
|
||||
Account = account,
|
||||
ServerIP = jsondata["area"].ToString(),
|
||||
LoginTime = jsondata["time"].ToString(),
|
||||
OnlineTime = jsondata["time"].ToString(),
|
||||
LoginIP = "",
|
||||
UpStream = "",
|
||||
DownStream = "",
|
||||
Id= "{number:\""+account+"\",session:\""+jsondata["session"].ToString()+"\"}",
|
||||
};
|
||||
|
||||
|
||||
retData.Add(trData);
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(retData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message + "-->info:" + info);
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(ResultCode.C_INVALID_ERROR, "查询失败");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> KillOut( string id)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("KillOut", id);
|
||||
var info = "";
|
||||
|
||||
JObject userinfo = (JObject)JsonConvert.DeserializeObject(id);
|
||||
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"number",userinfo["number"].ToString() },
|
||||
{"session",userinfo["session"].ToString() },
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var url = this.KIllUrl;
|
||||
|
||||
var resp = await client.PostAsForm(this.RefundUrl, map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["status"].ToString();
|
||||
if (status =="400")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message + "-->info:" + info);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> Exist(string account)
|
||||
{
|
||||
var ret = await this.GetAccountInfo(account);
|
||||
if (ret.Code != ResultCode.C_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,27 @@ namespace Hncore.Pass.Vpn.Service
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
public virtual string MD5(string password) {
|
||||
byte[] textBytes = System.Text.Encoding.Default.GetBytes(password);
|
||||
try {
|
||||
System.Security.Cryptography.MD5CryptoServiceProvider cryptHandler;
|
||||
cryptHandler = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||
byte[] hash = cryptHandler.ComputeHash (textBytes);
|
||||
string ret = "";
|
||||
foreach (byte a in hash) {
|
||||
if (a<16)
|
||||
ret += "0" + a.ToString ("x");
|
||||
else
|
||||
ret += a.ToString ("x");
|
||||
}
|
||||
return ret ;
|
||||
}
|
||||
catch {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void AddCookie(HttpClient client, string cookie)
|
||||
{
|
||||
client.DefaultRequestHeaders.Remove("Cookie");
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace Hncore.Pass.Vpn.Service
|
||||
agent = new AgentClient8Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g9")
|
||||
agent = new AgentClient9Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g10")
|
||||
agent = new AgentClient10Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
agent.Product = product;
|
||||
return agent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user