Skip to content

Commit

Permalink
Ability to change listener host.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankhommers committed Jun 1, 2015
1 parent ad7e8eb commit fca3ab8
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 78 deletions.
7 changes: 7 additions & 0 deletions KeePassHttp/ConfigOpt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ConfigOpt
const string ReturnStringFieldsKey = "KeePassHttp_ReturnStringFields";
const string SortResultByUsernameKey = "KeePassHttp_SortResultByUsername";
const string ListenerPortKey = "KeePassHttp_ListenerPort";
const string ListenerHostKey = "KeePassHttp_ListenerHost";

public ConfigOpt(AceCustomConfig config)
{
Expand Down Expand Up @@ -80,5 +81,11 @@ public long ListenerPort
get { return _config.GetLong(ListenerPortKey, KeePassHttpExt.DEFAULT_PORT); }
set { _config.SetLong(ListenerPortKey, value); }
}

public string ListenerHost
{
get { return _config.GetString(ListenerHostKey, KeePassHttpExt.DEFAULT_HOST); }
set { _config.SetString(ListenerHostKey, value); }
}
}
}
6 changes: 3 additions & 3 deletions KeePassHttp/KeePassHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public sealed partial class KeePassHttpExt : Plugin
private IPluginHost host;
private HttpListener listener;
public const int DEFAULT_PORT = 19455;
public const string DEFAULT_HOST = "localhost";
/// <summary>
/// TODO make configurable
/// </summary>
private int port = DEFAULT_PORT;
private const string HTTP_PREFIX = "http://localhost:";
private const string HTTP_SCHEME = "http://";
//private const string HTTPS_PREFIX = "https://localhost:";
//private int HTTPS_PORT = DEFAULT_PORT + 1;
private Thread httpThread;
Expand Down Expand Up @@ -201,7 +201,7 @@ public override bool Initialize(IPluginHost host)

var configOpt = new ConfigOpt(this.host.CustomConfig);

listener.Prefixes.Add(HTTP_PREFIX + configOpt.ListenerPort.ToString() + "/");
listener.Prefixes.Add(HTTP_SCHEME + configOpt.ListenerHost + ":" + configOpt.ListenerPort.ToString() + "/");
//listener.Prefixes.Add(HTTPS_PREFIX + HTTPS_PORT + "/");
listener.Start();

Expand Down
191 changes: 121 additions & 70 deletions KeePassHttp/OptionsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

1 comment on commit fca3ab8

@Owyn
Copy link

@Owyn Owyn commented on fca3ab8 Jul 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you compile this into plugin please? Downloaded and it's still not in options =(

Please sign in to comment.