You are not logged in.
Pages: 1
Hello,
I'm working with a THttpProxyServer.
I know I can add directories to it before creating the server. (settings.AddFolder(folder, url);)
1)What I'd like to know is how to dynamically add directories and map them to URLs after the server has been created and started?
2)Additionally, does THttpProxyServer support an IP whitelist? If so, how can I modify this list after the server has started?
Offline
Maybe you call call Stop method first, then Start again.
You can take a look at the source code of the AfterServerStarted() method, and then you can manually control fServer.Route function. The core statement is :
old := fServer.ReplaceRoute(new);
Offline
Regarding whitelist, you can check out THttpServer.Banned property which is THttpAcceptBan type that has some features about whitelist.
Offline
Thank you @zen010101
I just didn't understand about the whitelist.
Offline
Thank you @zen010101
I just didn't understand about the whitelist.
Sorry, I found that the WhiteIP property of THttpAccsptBan seems to only be able to contain one IP address that should not be banned.
/// a 32-bit IP4 which should never be banned
// - is set to cLocalhost32, i.e. 127.0.0.1, by default
property WhiteIP: cardinal
read fWhiteIP write fWhiteIP;
Offline
I couldn't find a solution to dynamically create a whitelist of IP addresses.
Offline
Thanks @ab.
I used it(OnBeforeBody) to create the whitelist and work fine.
Do you have any suggestions for adding and removing routes after starting the server without stopping it?
Since many methods of `THttpProxyUrl` are defined as `protected`, I cannot use them in my class. It seems I have to add a function for this in the `mormot.net.async` unit.
Offline
You have THttpServerGeneric.ReplaceRoute() which is not optimal, but should be thread-safe.
Or you can use TUriRouter.Clear then re-register all routes. TUriRouter should be thread-safe in itself.
But if you want to add or remove a set of routes, you may define all possible route URIs, then eventually reject some "removed/disabled" route URIs.
Or just don't use the routes, but good plain OnRequest().
Offline
Pages: 1