Added config options for RestApi
-IP now changes RestApi listening ip.
This commit is contained in:
parent
4b694c0c31
commit
f949738db9
3 changed files with 14 additions and 3 deletions
|
|
@ -193,6 +193,12 @@ namespace TShockAPI
|
|||
[Description("This is used when the API endpoint /status is queried.")]
|
||||
public string ServerNickname = "TShock Server";
|
||||
|
||||
[Description("Enable/Disable the rest api.")]
|
||||
public bool RestApiEnabled = true;
|
||||
|
||||
[Description("This is the port which the rest api will listen on.")]
|
||||
public int RestApiPort = 8080;
|
||||
|
||||
public static ConfigFile Read(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ namespace Rests
|
|||
|
||||
string hash;
|
||||
var rand = new Random();
|
||||
var randbytes = new byte[20];
|
||||
var randbytes = new byte[32];
|
||||
do
|
||||
{
|
||||
rand.NextBytes(randbytes);
|
||||
hash = Tools.HashPassword(randbytes);
|
||||
hash = randbytes.Aggregate("", (s, b) => s + b.ToString("X2"));
|
||||
} while (Tokens.ContainsKey(hash));
|
||||
|
||||
Tokens.Add(hash, user);
|
||||
|
|
@ -71,6 +71,8 @@ namespace Rests
|
|||
return obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override object ExecuteCommand(RestCommand cmd, RestVerbs verbs, IParameterCollection parms)
|
||||
{
|
||||
if (cmd.RequiesToken)
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ namespace TShockAPI
|
|||
RememberedPos = new RemeberedPosManager(DB);
|
||||
RestApi = new SecureRest(IPAddress.Any, 8080);
|
||||
RestApi.Verify += RestApi_Verify;
|
||||
RestApi.Port = Config.RestApiPort;
|
||||
RestManager = new RestManager(RestApi);
|
||||
RestManager.RegisterRestfulCommands();
|
||||
if (Config.EnableGeoIP)
|
||||
|
|
@ -307,6 +308,7 @@ namespace TShockAPI
|
|||
if (IPAddress.TryParse(parms[++i], out ip))
|
||||
{
|
||||
Netplay.serverListenIP = ip;
|
||||
RestApi.Ip = ip;
|
||||
Console.Write("Using IP: {0}", ip);
|
||||
}
|
||||
else
|
||||
|
|
@ -384,6 +386,7 @@ namespace TShockAPI
|
|||
AuthToken = 0;
|
||||
}
|
||||
Regions.ReloadAllRegions();
|
||||
if (Config.RestApiEnabled)
|
||||
RestApi.Start();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue