蘑菇
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
<p>·带宽6-10兆</p>
|
<p>·带宽6-10兆</p>
|
||||||
<p>·断开再链接换ip</p>
|
<p>·断开再链接换ip</p>
|
||||||
</ul>
|
</ul>
|
||||||
@foreach (var package in Model.Packages.Where(m=>m.IsTest==0&&m.Status==1&& m.Id != 1009).OrderBy(m => m.TenantId))
|
@foreach (var package in Model.Packages.Where(m=>m.IsTest==0&&m.Status==1&& m.Id != 1009&& m.Id != 1018&& m.Id != 1019&& m.Id != 1020).OrderBy(m => m.TenantId))
|
||||||
{
|
{
|
||||||
@if(package.Id == 101||package.Id == 103||package.Id == 104||(package.Id>103)){
|
@if(package.Id == 101||package.Id == 103||package.Id == 104||(package.Id>103)){
|
||||||
<a asp-action="rebuy" asp-controller="Product" asp-route-packageId="@package.Id" asp-route-accounts=@ViewBag.accounts>
|
<a asp-action="rebuy" asp-controller="Product" asp-route-packageId="@package.Id" asp-route-accounts=@ViewBag.accounts>
|
||||||
|
|||||||
@@ -266,7 +266,7 @@
|
|||||||
} *@
|
} *@
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@foreach (var package in Model.Packages.Where(m => m.IsTest == 0 && m.Status == 1&& m.Id != 1009&& m.Id != 1018).OrderBy(m => m.TenantId))
|
@foreach (var package in Model.Packages.Where(m => m.IsTest == 0 && m.Status == 1&& m.Id != 1009&& m.Id != 1018&& m.Id != 1019&& m.Id != 1020).OrderBy(m => m.TenantId))
|
||||||
{
|
{
|
||||||
@if(package.Id == 88||package.Id == 101||package.Id == 103||package.Id == 104||(package.Id>103 && package.Id>1000)){
|
@if(package.Id == 88||package.Id == 101||package.Id == 103||package.Id == 104||(package.Id>103 && package.Id>1000)){
|
||||||
|
|
||||||
|
|||||||
574
Services/Hncore.Pass.Vpn/Service/AgentClient9Service.cs
Normal file
574
Services/Hncore.Pass.Vpn/Service/AgentClient9Service.cs
Normal file
@@ -0,0 +1,574 @@
|
|||||||
|
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 AgentClient9Service: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 AgentClient9Service(IHttpClientFactory httpClientFactory):base(httpClientFactory)
|
||||||
|
{
|
||||||
|
m_HttpClientFactory = httpClientFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<int> RefrushStatus()
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
if (this.Token.Has())
|
||||||
|
{
|
||||||
|
var client = CreateHttpClient();
|
||||||
|
if (this.RefrushTokenUrl.Has())
|
||||||
|
{
|
||||||
|
// client.DefaultRequestHeaders.Add("Cookie", this.Token);
|
||||||
|
var getResp = await client.GetAsync(this.RefrushTokenUrl);
|
||||||
|
var content = await getResp.Content.ReadAsStringAsync();
|
||||||
|
if (getResp.StatusCode == HttpStatusCode.OK && content.IndexOf("agentLogin.html") == -1)
|
||||||
|
{
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.WriteLine("离线");
|
||||||
|
Debug.WriteLine(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
var client = CreateHttpClient(false);
|
||||||
|
|
||||||
|
var map = new Dictionary<string, string>(){
|
||||||
|
{"secret_id","yLeKmE6swXSk84VS" },
|
||||||
|
{"secret_key","bQYKH5hV5kcQ4bjaDHJBgM8PeUe82gwr" },
|
||||||
|
};
|
||||||
|
LogHelper.Info("Login", map.ToJson());
|
||||||
|
AddCookie(client, request.Key);
|
||||||
|
//client.DefaultRequestHeaders.Add("Cookie", request.Key);
|
||||||
|
var resp = await client.PostAsForm(this.LoginUrl, map);
|
||||||
|
var content = await resp.Content.ReadAsStringAsync();
|
||||||
|
if (content.IndexOf("alert alert-danger") != -1)
|
||||||
|
{
|
||||||
|
return new ApiResult(ResultCode.C_VISITOR_CHECKING, "登录失败");
|
||||||
|
}
|
||||||
|
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 client = CreateHttpClient();
|
||||||
|
var interval = "1";
|
||||||
|
if(packageKey == "2"){
|
||||||
|
interval ="2";
|
||||||
|
packageKey = "month";
|
||||||
|
} else if(packageKey == "3") {
|
||||||
|
interval ="2";
|
||||||
|
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 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 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);
|
||||||
|
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 " + get_token);
|
||||||
|
|
||||||
|
req.Timeout = 800;//请求超时时间
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||||
|
var retData = new List<OriginAccountOnlineModel>();
|
||||||
|
foreach (var tr in jo)
|
||||||
|
{
|
||||||
|
JObject jsondata = (JObject)JsonConvert.DeserializeObject(tr.ToJson());
|
||||||
|
|
||||||
|
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"]+"\"}",
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,6 +69,7 @@ namespace Hncore.Pass.Vpn.Service
|
|||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Remove("Cookie");
|
client.DefaultRequestHeaders.Remove("Cookie");
|
||||||
client.DefaultRequestHeaders.Add("Cookie", cookie);
|
client.DefaultRequestHeaders.Add("Cookie", cookie);
|
||||||
|
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + cookie);
|
||||||
}
|
}
|
||||||
public string GetCookie(HttpResponseMessage resp, string name)
|
public string GetCookie(HttpResponseMessage resp, string name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ namespace Hncore.Pass.Vpn.Service
|
|||||||
agent = new AgentClient7Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
agent = new AgentClient7Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||||
if (product.GroupNO == "g8")
|
if (product.GroupNO == "g8")
|
||||||
agent = new AgentClient8Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
agent = new AgentClient8Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||||
|
if (product.GroupNO == "g9")
|
||||||
|
agent = new AgentClient9Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||||
agent.Product = product;
|
agent.Product = product;
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
@@ -145,8 +147,8 @@ namespace Hncore.Pass.Vpn.Service
|
|||||||
account = accountInfo.Raw;
|
account = accountInfo.Raw;
|
||||||
}
|
}
|
||||||
var ret = await agent.GetAccountInfo(account);
|
var ret = await agent.GetAccountInfo(account);
|
||||||
if (ret.Code != ResultCode.C_SUCCESS) return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "账号不存在");
|
if (ret.Code != ResultCode.C_SUCCESS && product.Id!=17&& product.Id!=13) return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "账号不存在");
|
||||||
if (pwd.Has()&&ret.Data.Pwd != pwd)
|
if (pwd.Has()&&ret.Data.Pwd != pwd && product.Id!=17&& product.Id!=13)
|
||||||
return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "密码不正确");
|
return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "密码不正确");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -190,10 +192,6 @@ namespace Hncore.Pass.Vpn.Service
|
|||||||
var agent = GetAgent(product);
|
var agent = GetAgent(product);
|
||||||
agent.Init(product.BaseUrl, product.Token);
|
agent.Init(product.BaseUrl, product.Token);
|
||||||
|
|
||||||
Console.WriteLine("========================================================================");
|
|
||||||
Console.WriteLine(packageId);
|
|
||||||
Console.WriteLine(package.PackageType);
|
|
||||||
Console.WriteLine("========================================================================");
|
|
||||||
if (package.PackageType == PackageType.Base)
|
if (package.PackageType == PackageType.Base)
|
||||||
{
|
{
|
||||||
var ret = await agent.NewAccount(package.OriginKey, account, pwd, connCount, accountType,payCount);
|
var ret = await agent.NewAccount(package.OriginKey, account, pwd, connCount, accountType,payCount);
|
||||||
|
|||||||
Reference in New Issue
Block a user