mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 14:57:54 +00:00
feat: improve dispatch security
This commit is contained in:
parent
aa04124639
commit
45640f08ee
18 changed files with 893 additions and 269 deletions
|
|
@ -43,7 +43,7 @@ public struct UpdateDispatchData
|
|||
|
||||
public static class DispatchExt
|
||||
{
|
||||
public static StringContent GetPayloadBody(this UpdateDispatchData data)
|
||||
public static string GetPayloadBody(this UpdateDispatchData data)
|
||||
{
|
||||
var o = new JObject();
|
||||
|
||||
|
|
@ -53,7 +53,18 @@ public static class DispatchExt
|
|||
o.Add("id", data.EntityId);
|
||||
o.Add("data", data.EventData);
|
||||
|
||||
return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json");
|
||||
return JsonConvert.SerializeObject(o);
|
||||
}
|
||||
|
||||
public static string GetPingBody(string systemId, string token)
|
||||
{
|
||||
var o = new JObject();
|
||||
|
||||
o.Add("type", "PING");
|
||||
o.Add("signing_token", token);
|
||||
o.Add("system_id", systemId);
|
||||
|
||||
return JsonConvert.SerializeObject(o);
|
||||
}
|
||||
|
||||
private static List<IPNetwork> _privateNetworks = new()
|
||||
|
|
@ -71,6 +82,7 @@ public static class DispatchExt
|
|||
try
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
if (uri.Scheme != "https") return false;
|
||||
host = await Dns.GetHostEntryAsync(uri.DnsSafeHost);
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue