Hi,
I want to make a b4j server can only be accessed by localhost, the current plan is to use a filter thread for all requests.
Is there any other method? List all permutations is not very good ( e.g. 127.0.0.* is not included).
I want to make a b4j server can only be accessed by localhost, the current plan is to use a filter thread for all requests.
B4X:
srvr.AddFilter("/*","localhostfilter",False)
'Return True to allow the request to proceed.
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
Dim ip As String= req.RemoteAddress
Log(ip)
Dim ipmap As Map
ipmap.Initialize
'
ipmap.Put("localhost","")
ipmap.Put("LOCALHOST","")
ipmap.Put("127.0.0.1","")
ipmap.Put("0:0:0:0:0:0:0:1","")
ipmap.Put("::1","")
'... other permutations
If ipmap.ContainsKey(ip) Then
Return True
Else
Return False
End If
End Sub
Is there any other method? List all permutations is not very good ( e.g. 127.0.0.* is not included).