mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(bot): listen on multiple addresses, for v4/v6
This commit is contained in:
parent
f7b594e415
commit
3d0eb562bf
1 changed files with 14 additions and 6 deletions
|
|
@ -25,15 +25,23 @@ public class HttpListenerService
|
||||||
|
|
||||||
public void Start(string host)
|
public void Start(string host)
|
||||||
{
|
{
|
||||||
var server = new WebserverLite(new WebserverSettings(host, 5002), DefaultRoute);
|
var hosts = new[] { host };
|
||||||
|
if (host == "allv4v6")
|
||||||
|
{
|
||||||
|
hosts = new[] { "[::]", "0.0.0.0" };
|
||||||
|
}
|
||||||
|
foreach (var h in hosts)
|
||||||
|
{
|
||||||
|
var server = new WebserverLite(new WebserverSettings(h, 5002), DefaultRoute);
|
||||||
|
|
||||||
server.Routes.PreAuthentication.Static.Add(WatsonWebserver.Core.HttpMethod.GET, "/runtime_config", RuntimeConfigGet);
|
server.Routes.PreAuthentication.Static.Add(WatsonWebserver.Core.HttpMethod.GET, "/runtime_config", RuntimeConfigGet);
|
||||||
server.Routes.PreAuthentication.Parameter.Add(WatsonWebserver.Core.HttpMethod.POST, "/runtime_config/{key}", RuntimeConfigSet);
|
server.Routes.PreAuthentication.Parameter.Add(WatsonWebserver.Core.HttpMethod.POST, "/runtime_config/{key}", RuntimeConfigSet);
|
||||||
server.Routes.PreAuthentication.Parameter.Add(WatsonWebserver.Core.HttpMethod.DELETE, "/runtime_config/{key}", RuntimeConfigDelete);
|
server.Routes.PreAuthentication.Parameter.Add(WatsonWebserver.Core.HttpMethod.DELETE, "/runtime_config/{key}", RuntimeConfigDelete);
|
||||||
|
|
||||||
server.Routes.PreAuthentication.Parameter.Add(WatsonWebserver.Core.HttpMethod.POST, "/events/{shard_id}", GatewayEvent);
|
server.Routes.PreAuthentication.Parameter.Add(WatsonWebserver.Core.HttpMethod.POST, "/events/{shard_id}", GatewayEvent);
|
||||||
|
|
||||||
server.Start();
|
server.Start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DefaultRoute(HttpContextBase ctx)
|
private async Task DefaultRoute(HttpContextBase ctx)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue