Skip to content

Commit

Permalink
Merge pull request #217 from frankhommers/master
Browse files Browse the repository at this point in the history
Ability to change listener host.
  • Loading branch information
pfn committed Jun 13, 2015
2 parents ad7e8eb + fca3ab8 commit 3a29380
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

0 comments on commit 3a29380

Please sign in to comment.