mirror of
https://github.com/snltty/linker.git
synced 2025-12-19 01:46:46 +08:00
196
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
v1.9.6
|
||||
2025-11-21 16:56:23
|
||||
2025-11-21 17:46:17
|
||||
1. 一些累计更新,一些BUG修复
|
||||
2. 优化客户端数据同步,减少服务器流量
|
||||
3. 去除cdkey,改为发电解锁中继速度
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace linker.libs.extends
|
||||
AllowTrailingCommas = true,
|
||||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new IPAddressJsonConverter(), new IPEndpointJsonConverter(), new DateTimeJsonConverter(), new BitArrayJsonConverter(),new KeyValuePairJsonConverter<string,string>() }
|
||||
Converters = { new IPAddressJsonConverter(), new IPEndpointJsonConverter(), new DateTimeJsonConverter(), new BitArrayJsonConverter(), new KeyValuePairJsonConverter<string, string>() }
|
||||
};
|
||||
private static JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
|
||||
{
|
||||
@@ -52,5 +52,9 @@ namespace linker.libs.extends
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public sealed class KeyValueInfo<T1, T2>
|
||||
{
|
||||
public T1 Key { get; set; } = default(T1);
|
||||
public T2 Value { get; set; } = default(T2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace linker.messenger.action
|
||||
[Access(AccessValue.Action)]
|
||||
public async Task<bool> SetServerArgs(ApiControllerParamsInfo param)
|
||||
{
|
||||
KeyValuePairInfo keyValue = param.Content.DeJson<KeyValuePairInfo>();
|
||||
KeyValueInfo<string, string> keyValue = param.Content.DeJson<KeyValueInfo<string,string>>();
|
||||
|
||||
if (keyValue.Key == signInClientStore.Id || string.IsNullOrWhiteSpace(keyValue.Key))
|
||||
{
|
||||
@@ -69,10 +69,4 @@ namespace linker.messenger.action
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class KeyValuePairInfo
|
||||
{
|
||||
public string Key { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ namespace linker.messenger.relay.client
|
||||
return relayTestTransfer.Nodes;
|
||||
}
|
||||
|
||||
public KeyValuePairInfo GetDefault(ApiControllerParamsInfo param)
|
||||
public KeyValueInfo<string, TunnelProtocolType> GetDefault(ApiControllerParamsInfo param)
|
||||
{
|
||||
return new KeyValuePairInfo { Key = relayClientStore.DefaultNodeId, Value = relayClientStore.DefaultProtocol };
|
||||
return new KeyValueInfo<string, TunnelProtocolType> { Key = relayClientStore.DefaultNodeId, Value = relayClientStore.DefaultProtocol };
|
||||
}
|
||||
public async Task SyncDefault(ApiControllerParamsInfo param)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ namespace linker.messenger.relay.client
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Update(ApiControllerParamsInfo param)
|
||||
{
|
||||
UpdateInfo info = param.Content.DeJson<UpdateInfo>();
|
||||
KeyValueInfo<string, string> info = param.Content.DeJson<KeyValueInfo<string,string>>();
|
||||
var resp = await messengerSender.SendReply(new MessageRequestWrap
|
||||
{
|
||||
Connection = signInClientState.Connection,
|
||||
@@ -165,21 +165,10 @@ namespace linker.messenger.relay.client
|
||||
public ulong HashCode { get; set; }
|
||||
}
|
||||
|
||||
public sealed class UpdateInfo
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
public sealed class SyncInfo
|
||||
{
|
||||
public string[] Ids { get; set; } = [];
|
||||
public KeyValuePairInfo Data { get; set; } = new KeyValuePairInfo();
|
||||
}
|
||||
|
||||
public sealed class KeyValuePairInfo
|
||||
{
|
||||
public string Key { get; set; } = string.Empty;
|
||||
public TunnelProtocolType Value { get; set; } = TunnelProtocolType.Tcp;
|
||||
public KeyValueInfo<string, TunnelProtocolType> Data { get; set; } = new KeyValueInfo<string, TunnelProtocolType> { Key=string.Empty, Value= TunnelProtocolType.Tcp };
|
||||
}
|
||||
|
||||
public sealed class RelayConnectInfo
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace linker.messenger.sforward.client
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Update(ApiControllerParamsInfo param)
|
||||
{
|
||||
UpdateInfo info = param.Content.DeJson<UpdateInfo>();
|
||||
KeyValueInfo<string, string> info = param.Content.DeJson<KeyValueInfo<string,string>>();
|
||||
var resp = await messengerSender.SendReply(new MessageRequestWrap
|
||||
{
|
||||
Connection = signInClientState.Connection,
|
||||
@@ -227,11 +227,6 @@ namespace linker.messenger.sforward.client
|
||||
|
||||
}
|
||||
|
||||
public sealed class UpdateInfo
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
public sealed class SForwardListInfo
|
||||
{
|
||||
public ConcurrentDictionary<string, int> List { get; set; }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using linker.libs.extends;
|
||||
using System.Collections.Concurrent;
|
||||
using linker.tunnel.connection;
|
||||
using System.Net;
|
||||
using linker.libs;
|
||||
using linker.messenger.signin;
|
||||
@@ -218,7 +217,7 @@ namespace linker.messenger.tuntap
|
||||
}
|
||||
public async Task<bool> SetId(ApiControllerParamsInfo param)
|
||||
{
|
||||
SetIdKeyValueInfo info = param.Content.DeJson<SetIdKeyValueInfo>();
|
||||
KeyValueInfo<string, Guid> info = param.Content.DeJson<KeyValueInfo<string,Guid>>();
|
||||
if (info.Key == signInClientStore.Id)
|
||||
{
|
||||
tuntapConfigTransfer.SetID(info.Value);
|
||||
@@ -322,12 +321,6 @@ namespace linker.messenger.tuntap
|
||||
|
||||
}
|
||||
|
||||
public sealed class SetIdKeyValueInfo
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public Guid Value { get; set; }
|
||||
}
|
||||
|
||||
public sealed class TuntabListInfo
|
||||
{
|
||||
public ConcurrentDictionary<string, TuntapInfo> List { get; set; }
|
||||
|
||||
@@ -89,11 +89,12 @@ namespace linker.messenger.wlist
|
||||
/// <returns></returns>
|
||||
public async Task<WhiteListOrderStatusInfo> Status(ApiControllerParamsInfo param)
|
||||
{
|
||||
KeyValueInfo<string, string> info = param.Content.DeJson<KeyValueInfo<string, string>>();
|
||||
var resp = await messengerSender.SendReply(new MessageRequestWrap
|
||||
{
|
||||
Connection = signInClientState.Connection,
|
||||
MessengerId = (ushort)WhiteListMessengerIds.Status,
|
||||
Payload = serializer.Serialize(param.Content)
|
||||
Payload = serializer.Serialize(new KeyValuePair<string, string>(info.Key,info.Value))
|
||||
}).ConfigureAwait(false);
|
||||
if (resp.Code == MessageResponeCodes.OK && resp.Data.Span.SequenceEqual(Helper.FalseArray) == false)
|
||||
{
|
||||
@@ -125,7 +126,7 @@ namespace linker.messenger.wlist
|
||||
|
||||
public async Task<Dictionary<string, Dictionary<int, double>>> List(ApiControllerParamsInfo param)
|
||||
{
|
||||
KeyValueInfo info = param.Content.DeJson<KeyValueInfo>();
|
||||
KeyValueInfo<string,List<string>> info = param.Content.DeJson<KeyValueInfo<string,List<string>>>();
|
||||
|
||||
var resp = await messengerSender.SendReply(new MessageRequestWrap
|
||||
{
|
||||
@@ -140,11 +141,7 @@ namespace linker.messenger.wlist
|
||||
|
||||
return [];
|
||||
}
|
||||
sealed class KeyValueInfo
|
||||
{
|
||||
public string Key { get; set; } = string.Empty;
|
||||
public List<string> Value { get; set; } = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace linker.messenger.wlist
|
||||
private readonly IWhiteListServerStore whiteListServerStore;
|
||||
private readonly OrderTransfer orderTransfer;
|
||||
|
||||
public WhiteListServerMessenger( SignInServerCaching signCaching, ISerializer serializer, IWhiteListServerStore whiteListServerStore, OrderTransfer orderTransfer)
|
||||
public WhiteListServerMessenger(SignInServerCaching signCaching, ISerializer serializer, IWhiteListServerStore whiteListServerStore, OrderTransfer orderTransfer)
|
||||
{
|
||||
this.signCaching = signCaching;
|
||||
this.serializer = serializer;
|
||||
@@ -87,21 +87,32 @@ namespace linker.messenger.wlist
|
||||
[MessengerId((ushort)WhiteListMessengerIds.Status)]
|
||||
public async Task Status(IConnection connection)
|
||||
{
|
||||
string type = serializer.Deserialize<string>(connection.ReceiveRequestWrap.Payload.Span);
|
||||
if (signCaching.TryGet(connection.Id, out SignCacheInfo cache) == false)
|
||||
KeyValuePair<string, string> info;
|
||||
|
||||
try
|
||||
{
|
||||
info = serializer.Deserialize<KeyValuePair<string, string>>(connection.ReceiveRequestWrap.Payload.Span);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
string type = serializer.Deserialize<string>(connection.ReceiveRequestWrap.Payload.Span);
|
||||
info = new KeyValuePair<string, string>(type, connection.Id);
|
||||
}
|
||||
|
||||
if (signCaching.TryGet(connection.Id, out SignCacheInfo cache) == false || signCaching.TryGet(info.Value, out SignCacheInfo cacheTo) == false)
|
||||
{
|
||||
connection.Write(Helper.FalseArray);
|
||||
return;
|
||||
}
|
||||
|
||||
List<WhiteListInfo> list = await whiteListServerStore.Get(type, [cache.UserId], [cache.MachineId]).ConfigureAwait(false);
|
||||
WhiteListInfo info = list.FirstOrDefault(c => c.Bandwidth < 0) ?? list.FirstOrDefault(c => c.Bandwidth == 0) ?? list.OrderByDescending(c => c.Bandwidth).FirstOrDefault();
|
||||
List<WhiteListInfo> list = await whiteListServerStore.Get(info.Key, [cacheTo.UserId], [cacheTo.MachineId]).ConfigureAwait(false);
|
||||
WhiteListInfo result = list.FirstOrDefault(c => c.Bandwidth < 0) ?? list.FirstOrDefault(c => c.Bandwidth == 0) ?? list.OrderByDescending(c => c.Bandwidth).FirstOrDefault();
|
||||
|
||||
connection.Write(serializer.Serialize(new WhiteListOrderStatusInfo
|
||||
{
|
||||
Type = whiteListServerStore.Config.Type,
|
||||
Enabled = orderTransfer.CheckEnabled(),
|
||||
Info = info
|
||||
Info = result
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ export const wlistAdd = (data) => {
|
||||
export const wlistDel = (data) => {
|
||||
return sendWebsocketMsg('whitelist/Del', data);
|
||||
}
|
||||
export const wlistStatus = (type) => {
|
||||
return sendWebsocketMsg('whitelist/status', type);
|
||||
export const wlistStatus = (type,machineId) => {
|
||||
return sendWebsocketMsg('whitelist/status', {Key:type,Value:machineId});
|
||||
}
|
||||
export const wlistAddOrder = (data) => {
|
||||
return sendWebsocketMsg('whitelist/addorder', data);
|
||||
|
||||
@@ -179,9 +179,8 @@ export default {
|
||||
if(state.apply2user){
|
||||
json.UserId = state.machineids.filter(c=>c.MachineId == state.ruleForm.MachineId)[0].UserId;
|
||||
}
|
||||
json.UseTime = `${state.timeRange[0]} 00:00:00`;
|
||||
json.EndTime = `${state.timeRange[1]} 23:59:59`;
|
||||
|
||||
json.UseTime = `${moment(state.timeRange[0]).format('YYYY-MM-DD')} 00:00:00`;
|
||||
json.EndTime = `${moment(state.timeRange[1]).format('YYYY-MM-DD')} 23:59:59`;
|
||||
wlistAdd(json).then(()=>{
|
||||
ElMessage.success(t('common.oper'));
|
||||
state.show = false;
|
||||
|
||||
@@ -74,7 +74,8 @@ export default {
|
||||
});
|
||||
|
||||
const handleRefreshData = ()=>{
|
||||
wlistStatus(wlist.value.device.type).then(res=>{
|
||||
wlistStatus(wlist.value.device.type,wlist.value.device.id).then(res=>{
|
||||
|
||||
state.status = res;
|
||||
state.status.Info = res.Info || {}
|
||||
});
|
||||
@@ -111,7 +112,6 @@ export default {
|
||||
emit('change');
|
||||
}
|
||||
|
||||
|
||||
onMounted(()=>{
|
||||
handleRefreshData();
|
||||
});
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
|
||||
<script>
|
||||
import { wlistAddOrder, wlistStatus } from '@/apis/wlist';
|
||||
import { injectGlobalData } from '@/provide';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { onMounted, reactive } from 'vue';
|
||||
export default {
|
||||
props:['type'],
|
||||
setup (props) {
|
||||
|
||||
const globalData = injectGlobalData();
|
||||
const state = reactive({
|
||||
status:{}
|
||||
});
|
||||
@@ -41,7 +43,7 @@ export default {
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
wlistStatus(props.type).then(res=>{
|
||||
wlistStatus(props.type,globalData.value.config.Client.Id).then(res=>{
|
||||
state.status = res;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user