Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evo configuration des interfaces à binder pour l'AddOn HttpManager. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HttpEngine/AddOns/http/addon.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ server=http://127.0.0.1:8080
; Local HTTP server port
port=8888

; Interfaces to bind, separate by coma (ex: 192.168.0.2,192.168.1.12)
ip=

temp=AddOns/http/temp/
37 changes: 27 additions & 10 deletions HttpEngine/HttpManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,39 @@ public void SendFILE(string device, string url, string token, string path) {
public void StartHttpServer() {

int port = ConfigManager.GetInstance().Find("http.local.port", 8888);
IPAddress address = GetIpAddress();
List<IPAddress> addresses;

// 192.168.0.x
if (address != null) {
string configIps = ConfigManager.GetInstance().Find("http.local.ip", "");
if (String.IsNullOrWhiteSpace(configIps)) {
addresses.Add(GetIpAddress());
}
else {
string[] ips = configIps.Split(",");
try {
http = new HttpServer();
http.EndPoint = new IPEndPoint(address, port);
http.Start();
http.RequestReceived += this.http_RequestReceived;
Log("Starting Server: http://" + http.EndPoint + "/");
} catch (Exception ex) {
http = null;
foreach(string ip in ips) {
addresses.Add(IPAddress.Parse(ip));
}
} catch(Exception ex) {
Log("Exception: " + ex.Message);
}
}

foreach(IPAddress address in addresses) {
// 192.168.0.x
if (address != null) {
try {
http = new HttpServer();
http.EndPoint = new IPEndPoint(address, port);
http.Start();
http.RequestReceived += this.http_RequestReceived;
Log("Starting Server: http://" + http.EndPoint + "/");
} catch (Exception ex) {
http = null;
Log("Exception: " + ex.Message);
}
}
}

// Localhost
try {
local = new HttpServer();
Expand Down