mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 22:17:51 +01:00
Merge pull request #172 from Cyberboss/WhoCapitalizesIRCChannels
Unhardcodes the remote access port
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TGServiceInterface;
|
||||
|
||||
namespace TGCommandLine
|
||||
@@ -8,7 +9,7 @@ namespace TGCommandLine
|
||||
public AdminCommand()
|
||||
{
|
||||
Keyword = "admin";
|
||||
Children = new Command[] { new AdminViewGroupCommand(), new AdminSetGroupCommand(), new AdminClearGroupCommand() };
|
||||
Children = new Command[] { new AdminViewGroupCommand(), new AdminSetGroupCommand(), new AdminClearGroupCommand(), new AdminViewPortCommand(), new AdminSetPortCommand() };
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
@@ -16,6 +17,60 @@ namespace TGCommandLine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AdminSetPortCommand : Command
|
||||
{
|
||||
public AdminSetPortCommand()
|
||||
{
|
||||
Keyword = "set-port";
|
||||
RequiredParameters = 1;
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Set the port used for remote access. Requires a service restart to take effect";
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<port>";
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
ushort port;
|
||||
try
|
||||
{
|
||||
port = Convert.ToUInt16(parameters[0]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
OutputProc("Invalid port number!");
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
var res = Server.GetComponent<ITGAdministration>().SetRemoteAccessPort(port);
|
||||
OutputProc(res ?? "Success!");
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
class AdminViewPortCommand : Command {
|
||||
public AdminViewPortCommand()
|
||||
{
|
||||
Keyword = "view-port";
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Print the port currently designated for remote access";
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
var port = Server.GetComponent<ITGAdministration>().RemoteAccessPort();
|
||||
OutputProc(String.Format("{0}", port));
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
class AdminViewGroupCommand : Command
|
||||
{
|
||||
public AdminViewGroupCommand()
|
||||
|
||||
@@ -24,9 +24,25 @@ namespace TGCommandLine
|
||||
badConnectionString = true;
|
||||
break;
|
||||
}
|
||||
var addrport = splits[1].Split(':');
|
||||
if (addrport.Length != 2)
|
||||
{
|
||||
badConnectionString = true;
|
||||
break;
|
||||
}
|
||||
var username = userpass[0];
|
||||
var password = userpass[1];
|
||||
var address = splits[1];
|
||||
var address = addrport[0];
|
||||
ushort port;
|
||||
try
|
||||
{
|
||||
port = Convert.ToUInt16(addrport[1]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
badConnectionString = true;
|
||||
break;
|
||||
}
|
||||
if(String.IsNullOrWhiteSpace(username) || String.IsNullOrWhiteSpace(password) || String.IsNullOrWhiteSpace(address))
|
||||
{
|
||||
badConnectionString = true;
|
||||
@@ -34,14 +50,14 @@ namespace TGCommandLine
|
||||
}
|
||||
argsAsList.RemoveAt(I);
|
||||
argsAsList.RemoveAt(I);
|
||||
Server.SetRemoteLoginInformation(address, username, password);
|
||||
Server.SetRemoteLoginInformation(address, port, username, password);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (badConnectionString)
|
||||
{
|
||||
Console.WriteLine("Remote connection usage: <-c/--connect> username:password@address");
|
||||
Console.WriteLine("Remote connection usage: <-c/--connect> username:password@address:port");
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
|
||||
@@ -49,7 +65,7 @@ namespace TGCommandLine
|
||||
if (res != null)
|
||||
{
|
||||
Console.WriteLine("Unable to connect to service: " + res);
|
||||
Console.WriteLine("Remote connection usage: <-c/--connect> username:password@address");
|
||||
Console.WriteLine("Remote connection usage: <-c/--connect> username:password@address:port");
|
||||
return ExitCode.ConnectionError;
|
||||
}
|
||||
|
||||
@@ -114,21 +130,31 @@ namespace TGCommandLine
|
||||
case "remote":
|
||||
Console.Write("Enter server address: ");
|
||||
var address = Console.ReadLine();
|
||||
Console.Write("Enter server port: ");
|
||||
ushort port;
|
||||
try{
|
||||
port = Convert.ToUInt16(Console.ReadLine());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Error: Bad port!");
|
||||
break;
|
||||
}
|
||||
Console.Write("Enter username: ");
|
||||
var username = Console.ReadLine();
|
||||
Console.Write("Enter password: ");
|
||||
var password = ReadLineSecure();
|
||||
Server.SetRemoteLoginInformation(address, username, password);
|
||||
Server.SetRemoteLoginInformation(address, port, username, password);
|
||||
var res = Server.VerifyConnection();
|
||||
if (res != null)
|
||||
{
|
||||
Console.WriteLine("Unable to connect: " + res);
|
||||
Server.SetRemoteLoginInformation(null, null, null);
|
||||
Server.SetRemoteLoginInformation(null, 0, null, null);
|
||||
}
|
||||
else if (!Server.Authenticate())
|
||||
{
|
||||
Console.WriteLine("Authentication error: Username/password/windows identity is not authorized! Returning to local mode...");
|
||||
Server.SetRemoteLoginInformation(null, null, null);
|
||||
Server.SetRemoteLoginInformation(null, 0, null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,7 +163,7 @@ namespace TGCommandLine
|
||||
}
|
||||
break;
|
||||
case "disconnect":
|
||||
Server.SetRemoteLoginInformation(null, null, null);
|
||||
Server.SetRemoteLoginInformation(null, 0, null, null);
|
||||
Console.WriteLine("Switch to local mode");
|
||||
break;
|
||||
case "quit":
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
<setting name="RemoteUsername" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="RemotePort" serializeAs="String">
|
||||
<value>38607</value>
|
||||
</setting>
|
||||
</TGControlPanel.Properties.Settings>
|
||||
<TGControlPanel.Properties.Settings1>
|
||||
<setting name="LastPageIndex" serializeAs="String">
|
||||
|
||||
Generated
+168
-141
@@ -28,146 +28,172 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Login));
|
||||
this.LocalLoginButton = new System.Windows.Forms.Button();
|
||||
this.CurrentRevisionTitle = new System.Windows.Forms.Label();
|
||||
this.IPTextBox = new System.Windows.Forms.TextBox();
|
||||
this.UsernameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemoteLoginButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// LocalLoginButton
|
||||
//
|
||||
this.LocalLoginButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.LocalLoginButton.Location = new System.Drawing.Point(51, 12);
|
||||
this.LocalLoginButton.Name = "LocalLoginButton";
|
||||
this.LocalLoginButton.Size = new System.Drawing.Size(188, 25);
|
||||
this.LocalLoginButton.TabIndex = 13;
|
||||
this.LocalLoginButton.Text = "Connect to Local Service";
|
||||
this.LocalLoginButton.UseVisualStyleBackColor = true;
|
||||
this.LocalLoginButton.Click += new System.EventHandler(this.LocalLoginButton_Click);
|
||||
//
|
||||
// CurrentRevisionTitle
|
||||
//
|
||||
this.CurrentRevisionTitle.AutoSize = true;
|
||||
this.CurrentRevisionTitle.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.CurrentRevisionTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.CurrentRevisionTitle.Location = new System.Drawing.Point(81, 76);
|
||||
this.CurrentRevisionTitle.Name = "CurrentRevisionTitle";
|
||||
this.CurrentRevisionTitle.Size = new System.Drawing.Size(128, 18);
|
||||
this.CurrentRevisionTitle.TabIndex = 14;
|
||||
this.CurrentRevisionTitle.Text = "Remote Login:";
|
||||
this.CurrentRevisionTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// IPTextBox
|
||||
//
|
||||
this.IPTextBox.Location = new System.Drawing.Point(73, 97);
|
||||
this.IPTextBox.Name = "IPTextBox";
|
||||
this.IPTextBox.Size = new System.Drawing.Size(199, 20);
|
||||
this.IPTextBox.TabIndex = 15;
|
||||
//
|
||||
// UsernameTextBox
|
||||
//
|
||||
this.UsernameTextBox.Location = new System.Drawing.Point(73, 130);
|
||||
this.UsernameTextBox.Name = "UsernameTextBox";
|
||||
this.UsernameTextBox.Size = new System.Drawing.Size(199, 20);
|
||||
this.UsernameTextBox.TabIndex = 16;
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(73, 162);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(199, 20);
|
||||
this.PasswordTextBox.TabIndex = 17;
|
||||
this.PasswordTextBox.UseSystemPasswordChar = true;
|
||||
//
|
||||
// RemoteLoginButton
|
||||
//
|
||||
this.RemoteLoginButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.RemoteLoginButton.Location = new System.Drawing.Point(51, 197);
|
||||
this.RemoteLoginButton.Name = "RemoteLoginButton";
|
||||
this.RemoteLoginButton.Size = new System.Drawing.Size(188, 25);
|
||||
this.RemoteLoginButton.TabIndex = 18;
|
||||
this.RemoteLoginButton.Text = "Connect to Remote Service";
|
||||
this.RemoteLoginButton.UseVisualStyleBackColor = true;
|
||||
this.RemoteLoginButton.Click += new System.EventHandler(this.RemoteLoginButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label1.Location = new System.Drawing.Point(9, 99);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(32, 18);
|
||||
this.label1.TabIndex = 19;
|
||||
this.label1.Text = "IP:";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label2.Location = new System.Drawing.Point(9, 132);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(52, 18);
|
||||
this.label2.TabIndex = 20;
|
||||
this.label2.Text = "User:";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label3.Location = new System.Drawing.Point(9, 164);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(53, 18);
|
||||
this.label3.TabIndex = 21;
|
||||
this.label3.Text = "Pass:";
|
||||
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label4.Location = new System.Drawing.Point(-19, 40);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(468, 18);
|
||||
this.label4.TabIndex = 22;
|
||||
this.label4.Text = "______________________________________________";
|
||||
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// Login
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34)))));
|
||||
this.ClientSize = new System.Drawing.Size(284, 237);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.RemoteLoginButton);
|
||||
this.Controls.Add(this.PasswordTextBox);
|
||||
this.Controls.Add(this.UsernameTextBox);
|
||||
this.Controls.Add(this.IPTextBox);
|
||||
this.Controls.Add(this.CurrentRevisionTitle);
|
||||
this.Controls.Add(this.LocalLoginButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Login";
|
||||
this.Text = "Login";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Login));
|
||||
this.LocalLoginButton = new System.Windows.Forms.Button();
|
||||
this.CurrentRevisionTitle = new System.Windows.Forms.Label();
|
||||
this.IPTextBox = new System.Windows.Forms.TextBox();
|
||||
this.UsernameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemoteLoginButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.PortSelector = new System.Windows.Forms.NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PortSelector)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// LocalLoginButton
|
||||
//
|
||||
this.LocalLoginButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.LocalLoginButton.Location = new System.Drawing.Point(87, 12);
|
||||
this.LocalLoginButton.Name = "LocalLoginButton";
|
||||
this.LocalLoginButton.Size = new System.Drawing.Size(188, 25);
|
||||
this.LocalLoginButton.TabIndex = 13;
|
||||
this.LocalLoginButton.Text = "Connect to Local Service";
|
||||
this.LocalLoginButton.UseVisualStyleBackColor = true;
|
||||
this.LocalLoginButton.Click += new System.EventHandler(this.LocalLoginButton_Click);
|
||||
//
|
||||
// CurrentRevisionTitle
|
||||
//
|
||||
this.CurrentRevisionTitle.AutoSize = true;
|
||||
this.CurrentRevisionTitle.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.CurrentRevisionTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.CurrentRevisionTitle.Location = new System.Drawing.Point(116, 69);
|
||||
this.CurrentRevisionTitle.Name = "CurrentRevisionTitle";
|
||||
this.CurrentRevisionTitle.Size = new System.Drawing.Size(128, 18);
|
||||
this.CurrentRevisionTitle.TabIndex = 14;
|
||||
this.CurrentRevisionTitle.Text = "Remote Login:";
|
||||
this.CurrentRevisionTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// IPTextBox
|
||||
//
|
||||
this.IPTextBox.Location = new System.Drawing.Point(129, 99);
|
||||
this.IPTextBox.Name = "IPTextBox";
|
||||
this.IPTextBox.Size = new System.Drawing.Size(146, 20);
|
||||
this.IPTextBox.TabIndex = 15;
|
||||
//
|
||||
// UsernameTextBox
|
||||
//
|
||||
this.UsernameTextBox.Location = new System.Drawing.Point(129, 132);
|
||||
this.UsernameTextBox.Name = "UsernameTextBox";
|
||||
this.UsernameTextBox.Size = new System.Drawing.Size(233, 20);
|
||||
this.UsernameTextBox.TabIndex = 16;
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(129, 164);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(233, 20);
|
||||
this.PasswordTextBox.TabIndex = 17;
|
||||
this.PasswordTextBox.UseSystemPasswordChar = true;
|
||||
//
|
||||
// RemoteLoginButton
|
||||
//
|
||||
this.RemoteLoginButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.RemoteLoginButton.Location = new System.Drawing.Point(87, 200);
|
||||
this.RemoteLoginButton.Name = "RemoteLoginButton";
|
||||
this.RemoteLoginButton.Size = new System.Drawing.Size(188, 25);
|
||||
this.RemoteLoginButton.TabIndex = 18;
|
||||
this.RemoteLoginButton.Text = "Connect to Remote Service";
|
||||
this.RemoteLoginButton.UseVisualStyleBackColor = true;
|
||||
this.RemoteLoginButton.Click += new System.EventHandler(this.RemoteLoginButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label1.Location = new System.Drawing.Point(9, 99);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(120, 18);
|
||||
this.label1.TabIndex = 19;
|
||||
this.label1.Text = "Address/Port:";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label2.Location = new System.Drawing.Point(9, 132);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(97, 18);
|
||||
this.label2.TabIndex = 20;
|
||||
this.label2.Text = "Username:";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label3.Location = new System.Drawing.Point(9, 164);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(92, 18);
|
||||
this.label3.TabIndex = 21;
|
||||
this.label3.Text = "Password:";
|
||||
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.label4.Location = new System.Drawing.Point(-19, 40);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(468, 18);
|
||||
this.label4.TabIndex = 22;
|
||||
this.label4.Text = "______________________________________________";
|
||||
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// PortSelector
|
||||
//
|
||||
this.PortSelector.Location = new System.Drawing.Point(282, 99);
|
||||
this.PortSelector.Maximum = new decimal(new int[] {
|
||||
65535,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.PortSelector.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.PortSelector.Name = "PortSelector";
|
||||
this.PortSelector.Size = new System.Drawing.Size(80, 20);
|
||||
this.PortSelector.TabIndex = 23;
|
||||
this.PortSelector.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// Login
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34)))));
|
||||
this.ClientSize = new System.Drawing.Size(374, 237);
|
||||
this.Controls.Add(this.PortSelector);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.RemoteLoginButton);
|
||||
this.Controls.Add(this.PasswordTextBox);
|
||||
this.Controls.Add(this.UsernameTextBox);
|
||||
this.Controls.Add(this.IPTextBox);
|
||||
this.Controls.Add(this.CurrentRevisionTitle);
|
||||
this.Controls.Add(this.LocalLoginButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Login";
|
||||
this.Text = "Login";
|
||||
((System.ComponentModel.ISupportInitialize)(this.PortSelector)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -183,5 +209,6 @@
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
}
|
||||
private System.Windows.Forms.NumericUpDown PortSelector;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,9 @@ namespace TGControlPanel
|
||||
{
|
||||
InitializeComponent();
|
||||
IPTextBox.Text = Properties.Settings.Default.RemoteIP;
|
||||
UsernameTextBox.Text = Properties.Settings.Default.RemoteUsername;
|
||||
var Config = Properties.Settings.Default;
|
||||
UsernameTextBox.Text = Config.RemoteUsername;
|
||||
PortSelector.Value = Config.RemotePort;
|
||||
AcceptButton = RemoteLoginButton;
|
||||
}
|
||||
|
||||
@@ -18,7 +20,7 @@ namespace TGControlPanel
|
||||
{
|
||||
IPTextBox.Text = IPTextBox.Text.Trim();
|
||||
UsernameTextBox.Text = UsernameTextBox.Text.Trim();
|
||||
Server.SetRemoteLoginInformation(IPTextBox.Text, UsernameTextBox.Text, PasswordTextBox.Text);
|
||||
Server.SetRemoteLoginInformation(IPTextBox.Text, (ushort)PortSelector.Value, UsernameTextBox.Text, PasswordTextBox.Text);
|
||||
Properties.Settings.Default.RemoteIP = IPTextBox.Text;
|
||||
Properties.Settings.Default.RemoteUsername = UsernameTextBox.Text;
|
||||
VerifyAndConnect();
|
||||
@@ -26,7 +28,7 @@ namespace TGControlPanel
|
||||
|
||||
private void LocalLoginButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Server.SetRemoteLoginInformation(null, null, null);
|
||||
Server.SetRemoteLoginInformation(null, 0, null, null);
|
||||
VerifyAndConnect();
|
||||
}
|
||||
|
||||
|
||||
+13
-1
@@ -12,7 +12,7 @@ namespace TGControlPanel.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -94,5 +94,17 @@ namespace TGControlPanel.Properties {
|
||||
this["RemoteUsername"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("38607")]
|
||||
public ushort RemotePort {
|
||||
get {
|
||||
return ((ushort)(this["RemotePort"]));
|
||||
}
|
||||
set {
|
||||
this["RemotePort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,8 @@
|
||||
<Setting Name="RemoteUsername" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="RemotePort" Type="System.UInt16" Scope="User">
|
||||
<Value Profile="(Default)">38607</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
using System.Security.Principal;
|
||||
using System.ServiceModel;
|
||||
@@ -109,5 +108,22 @@ namespace TGServerService
|
||||
TGServerService.WriteAccess(operationContext.ServiceSecurityContext.WindowsIdentity.Name, authSuccess);
|
||||
return authSuccess;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ushort RemoteAccessPort()
|
||||
{
|
||||
return Properties.Settings.Default.RemoteAccessPort;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string SetRemoteAccessPort(ushort port)
|
||||
{
|
||||
if (port == 0)
|
||||
return "Cannot bind to port 0";
|
||||
var Config = Properties.Settings.Default;
|
||||
Config.RemoteAccessPort = port;
|
||||
Config.Save();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
<setting name="AuthorizedGroupSID" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="RemoteAccessPort" serializeAs="String">
|
||||
<value>38607</value>
|
||||
</setting>
|
||||
</TGServerService.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
||||
+13
-1
@@ -12,7 +12,7 @@ namespace TGServerService.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -262,5 +262,17 @@ namespace TGServerService.Properties {
|
||||
this["AuthorizedGroupSID"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("38607")]
|
||||
public ushort RemoteAccessPort {
|
||||
get {
|
||||
return ((ushort)(this["RemoteAccessPort"]));
|
||||
}
|
||||
set {
|
||||
this["RemoteAccessPort"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,5 +62,8 @@
|
||||
<Setting Name="AuthorizedGroupSID" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="RemoteAccessPort" Type="System.UInt16" Scope="User">
|
||||
<Value Profile="(Default)">38607</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -111,7 +111,7 @@ namespace TGServerService
|
||||
if (oldVersion == newVersion && newVersion == 0) //chat refactor
|
||||
Properties.Settings.Default.ChatProviderData = "NEEDS INITIALIZING"; //reset chat settings to be safe
|
||||
}
|
||||
|
||||
|
||||
//you should seriously not add anything here
|
||||
//Use OnStart instead
|
||||
public TGServerService()
|
||||
@@ -153,7 +153,15 @@ namespace TGServerService
|
||||
|
||||
var instance = new TGStationServer();
|
||||
|
||||
host = new ServiceHost(instance, new Uri[] { new Uri("net.pipe://localhost"), new Uri(String.Format("https://localhost:{0}", Server.HTTPSPort)) })
|
||||
for (var I = 0; I < args.Length - 1; ++I)
|
||||
if (args[I].ToLower() == "-port")
|
||||
{
|
||||
Config.RemoteAccessPort = Convert.ToUInt16(args[I + 1]);
|
||||
Config.Save();
|
||||
break;
|
||||
}
|
||||
|
||||
host = new ServiceHost(instance, new Uri[] { new Uri("net.pipe://localhost"), new Uri(String.Format("https://localhost:{0}", Config.RemoteAccessPort)) })
|
||||
{
|
||||
CloseTimeout = new TimeSpan(0, 0, 5)
|
||||
};
|
||||
@@ -164,7 +172,14 @@ namespace TGServerService
|
||||
host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, Config.CertificateURL);
|
||||
host.Authorization.ServiceAuthorizationManager = instance;
|
||||
|
||||
host.Open(); //...or maybe here, doesn't really matter
|
||||
try
|
||||
{
|
||||
host.Open();
|
||||
}
|
||||
catch (AddressAlreadyInUseException e)
|
||||
{
|
||||
throw new Exception("Can't start the service due to the configured remote access port being in use. To fix this change it by starting the service with the \"-port <port>\" argument.", e);
|
||||
}
|
||||
}
|
||||
|
||||
//shorthand for adding the WCF endpoint
|
||||
|
||||
@@ -8,6 +8,22 @@ namespace TGServiceInterface
|
||||
[ServiceContract]
|
||||
public interface ITGAdministration
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the port used for remote operation
|
||||
/// </summary>
|
||||
/// <returns>The port used for remote operation</returns>
|
||||
[OperationContract]
|
||||
ushort RemoteAccessPort();
|
||||
|
||||
/// <summary>
|
||||
/// Set the port used for remote operation
|
||||
/// Requires a service restart to take effect
|
||||
/// </summary>
|
||||
/// <param name="port">The new port to use for remote operation</param>
|
||||
/// <returns>null on success, error message on failure</returns>
|
||||
[OperationContract]
|
||||
string SetRemoteAccessPort(ushort port);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the windows group allowed to use the service other than administrator
|
||||
/// </summary>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace TGServiceInterface
|
||||
/// <summary>
|
||||
/// The port used by the service
|
||||
/// </summary>
|
||||
public const ushort HTTPSPort = 38607;
|
||||
static ushort HTTPSPort = 38607;
|
||||
|
||||
/// <summary>
|
||||
/// Username for remote operations
|
||||
@@ -50,9 +50,10 @@ namespace TGServiceInterface
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="port"></param>
|
||||
public static void SetRemoteLoginInformation(string address, string username, string password)
|
||||
public static void SetRemoteLoginInformation(string address, ushort port, string username, string password)
|
||||
{
|
||||
HTTPSURL = address;
|
||||
HTTPSPort = port;
|
||||
HTTPSUsername = username;
|
||||
HTTPSPassword = password;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ServiceModel;
|
||||
using System.ServiceModel;
|
||||
|
||||
namespace TGServiceInterface
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user