IP Filter -> Filter multiple consoles/machines

For help and support with PS3 Media Server in general
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply.

IP Filter -> Filter multiple consoles/machines

Postby stephan » Sat May 16, 2009 2:34 am

I am running PMS v1.10.51 under Windows 7 RC1 64 Bit. Everything works great on my playstation 3 and Xbox 360. Because I am on a network with multiple users I want to allow only the PS3 and Xbox 360 to use the Media Server. For one console this is achieved simply by adding the IP of the console at "ip filter". But I cant get it to work with adding two ip's.


(PS3 = 192.168.1.107, Xbox 360 = 192.168.1.112)
What I tried so far in PMS.conf,
ip_filter = 192.168.1.107,192.168.1.112
ip_filter = 192.168.1.107, 192.168.1.112
ip_filter = 192.168.1.107 192.168.1.112

None of the above worked.
When connecting with the PS3 the trace log indicates: [Thread-4] TRACE 09:07:21.685 Ignoring request from: 192.168.1.107
When connecting with the Xbox the trace log indicates nothing. But at xbox I get a "probably a firewall is blocking the connection..."-error when connecting.

Does anyone know if this is possible, and if yes, how?
stephan
 
Posts: 4
Joined: Sat May 16, 2009 2:26 am

Re: IP Filter -> Filter multiple consoles/machines

Postby stephan » Mon May 18, 2009 1:34 pm

no one with a solution? :oops:
stephan
 
Posts: 4
Joined: Sat May 16, 2009 2:26 am

Re: IP Filter -> Filter multiple consoles/machines

Postby pmos69 » Mon May 18, 2009 2:54 pm

I think current ipfilter is very simple and prepared for only one IP.
Support for multiple IPs should not be hard to implement though.
/me thinks you should open a request.
pmos69
 
Posts: 147
Joined: Mon Jan 19, 2009 3:37 pm

Re: IP Filter -> Filter multiple consoles/machines

Postby stephan » Mon May 18, 2009 4:53 pm

If this isnt possible I ll open a request indeed. An IP Filter with multiple ip's would be very nice. Maybe also possible to combine this with a MAC adress filter. :)
stephan
 
Posts: 4
Joined: Sat May 16, 2009 2:26 am

Re: IP Filter -> Filter multiple consoles/machines

Postby Dave114 » Sat Sep 24, 2011 10:09 pm

So here's a patch that should solve this issue - how might I go about submitting it for inclusion?.

Simply feed in a comma-separated list of addresses like "192.168.1.1,1.2.3.4" that you want to be able to access the machine. Thought about adding MAC address filtering as well, but Java doesn't really seem to offer a way to access the client MAC address.

Tested on my PS3 with IP filters off as well as with IP filter on and both including and excluding the machine.

Code: Select all
diff -Naur ps3mediaserver.clean/net/pms/network/HTTPServer.java ps3mediaserver.build/net/pms/network/HTTPServer.java
--- ps3mediaserver.clean/net/pms/network/HTTPServer.java   2011-09-24 04:48:22.000000000 -0600
+++ ps3mediaserver.build/net/pms/network/HTTPServer.java   2011-09-24 07:23:29.000000000 -0600
@@ -28,7 +28,7 @@
 import java.net.SocketAddress;
 import java.nio.channels.ClosedByInterruptException;
 import java.nio.channels.ServerSocketChannel;
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.concurrent.Executors;
 
@@ -47,7 +47,6 @@
 
 public class HTTPServer implements Runnable {
    private static final Logger logger = LoggerFactory.getLogger(HTTPServer.class);
-   private ArrayList<String> ips;
    private int port;
    private String hostName;
    private ServerSocketChannel serverSocketChannel;
@@ -67,7 +66,6 @@
 
    public HTTPServer(int port) {
       this.port = port;
-      ips = new ArrayList<String>();
    }
 
    public boolean start() throws IOException {
@@ -197,21 +195,19 @@
             Socket socket = serverSocket.accept();
             String ip = socket.getInetAddress().getHostAddress();
             // basic ipfilter solntcev@gmail.com
-            boolean ignore = false;
-            if (!ips.contains(ip)) {
-               if (PMS.getConfiguration().getIpFilter().length() > 0 && !PMS.getConfiguration().getIpFilter().equals(ip)) {
-                  ignore = true;
-                  socket.close();
-                  logger.info("Ignoring request from: " + ip);
-               } else {
-                  ips.add(ip);
-                  logger.info("Receiving a request from: " + ip);
-               }
-            }
-            if (!ignore) {
+            // revised by Dave114
+            String[] permittedIPs = PMS.getConfiguration().getIpFilter().split(",");
+            
+            if (PMS.getConfiguration().getIpFilter().length() < 1
+                  || Arrays.asList(permittedIPs).contains(ip)) {
+               // May now see multiple notifications like this
+               logger.info("Receiving a request from: " + ip);            
                RequestHandler request = new RequestHandler(socket);
                Thread thread = new Thread(request);
                thread.start();
+            } else {
+               socket.close();
+               logger.info("Ignoring request from: " + ip);                     
             }
          } catch (ClosedByInterruptException e) {
             stop = true;
diff -Naur ps3mediaserver.clean/net/pms/network/UPNPHelper.java ps3mediaserver.build/net/pms/network/UPNPHelper.java
--- ps3mediaserver.clean/net/pms/network/UPNPHelper.java   2011-09-24 04:48:22.000000000 -0600
+++ ps3mediaserver.build/net/pms/network/UPNPHelper.java   2011-09-24 07:23:29.000000000 -0600
@@ -26,6 +26,7 @@
 import java.net.MulticastSocket;
 import java.net.NetworkInterface;
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Locale;
@@ -229,7 +230,9 @@
                         String remoteAddr = packet_r.getAddress().getHostAddress();
                         int remotePort = packet_r.getPort();
 
-                        if (!(PMS.getConfiguration().getIpFilter().length() > 0 && !PMS.getConfiguration().getIpFilter().equals(remoteAddr))) {
+                        String[] allowedIPs = PMS.getConfiguration().getIpFilter().split(",");
+                        if (PMS.getConfiguration().getIpFilter().length() < 1
+                              || Arrays.asList(allowedIPs).contains(remoteAddr)) {
                            logger.trace("Receiving a M-SEARCH from [" + remoteAddr + ":" + remotePort + "]");
                            //logger.trace("Data: " + s);
 


Note that I'm currently seeing error messages relating to not being able to find "osx/convert", but I'm seeing this on both the official version of 1.40.0 and my builds.
Dave114
 
Posts: 12
Joined: Sat Sep 24, 2011 12:31 pm

Re: IP Filter -> Filter multiple consoles/machines

Postby ExSport » Sat Sep 24, 2011 10:42 pm

Nice but for most of people useless because they are using HTTP v2 engine.
ExSport
 
Posts: 2161
Joined: Mon Jan 19, 2009 5:40 pm

Re: IP Filter -> Filter multiple consoles/machines

Postby Dave114 » Sat Sep 24, 2011 10:48 pm

I'm confused. My OS X config shows "HTTP Engine V2" checked so I'm assuming that that's what I've got running (it's based on source checked out from the repository yesterday). So what am I missing that makes this useless?
Dave114
 
Posts: 12
Joined: Sat Sep 24, 2011 12:31 pm

Re: IP Filter -> Filter multiple consoles/machines

Postby Dave114 » Sun Sep 25, 2011 12:40 am

Looks like this - https://code.google.com/p/ps3mediaserve ... 626&id=626 - gives me a starting point from which to get IP filtering working for the v2 engine. Hopefully will have a new patch out later today with this.
Dave114
 
Posts: 12
Joined: Sat Sep 24, 2011 12:31 pm


Return to General Help and Support

Who is online

Users browsing this forum: No registered users and 8 guests