marcussacana / DirectPackageInstaller

Send Direct PKG URLs to your PS4
GNU General Public License v3.0
221 stars 23 forks source link

Specify port #66

Open Anuskuss opened 4 weeks ago

Anuskuss commented 4 weeks ago

Allow the user to specify the port instead of choosing a random one, e.g. dotnet DirectPackageInstaller.Desktop.dll -Server 192.168.0.1 -PS4 192.168.0.2 -Port 9090 http://192.168.0.1/ps4.pkg

There's also the hardcoded port 9898. Could you rewrite DPI such that all communication happens on a single port? Or if not, could you also make this configurable (e.g. -Port 9898 -PayloadPort 9090).

marcussacana commented 4 weeks ago

The process of DPI starts a download is a bit confusing as you can see:

flowchart TD
    B(Http Server) --> A[/DirectPackageInstaller/]   
    C(PKG Info Server) --> A
    D{HTTP PORT 9898} --> B
    E{Random Port} --> C 
    G(Payload Server 9090) --> F[GoldHEN]
    D --> J[/PS4 BGFT Download/]
    A --> G
    H[DPI PS4 Service] --> E
    H --> J
    F --> H
    B ~~~~ D

One of the key reason for that port be random is this complexity, I wanted made the things simple as possible for the users does not need setup the envoriment, Theorically the users shoudn't even lose his time setting the PS4/PC IP, even more with the ports. The HTTP Port is fixed only due the fact that would broke the downloads from an older instance of DPI if not. My preference is let the operating system handle that has possible and pick an port with enought privileges to listen it. There are another reason that made me favor the random port: Security The DPI payload is basically an code that is injected in your system and install something automatically, the fact that the port is select randomly means that you doesn't expect to that "PKG Info Server" port be allowed in the router firewall, making the payload usable only behind LAN. While is possible to me adapt to run in custom ports is really something that I have my worries, I need to think a bit about it.

Anuskuss commented 4 weeks ago

the fact that the port is select randomly means that you doesn't expect to that "PKG Info Server" port be allowed in the router firewall, making the payload usable only behind LAN.

All my ports are closed (even for my LAN) unless I manually opened them. So I need to know which port is going to be used so I can open it.

The HTTP Port is fixed only due the fact that would broke the downloads from an older instance of DPI if not.

More importantely, you are already listening on port TCP/9898. So you could theoretically halt the Payload server and let the HTTP server listen (or vice versa). Or just embed a minimal HTTP server (e.g. civetweb). Or even better give us the ability to specify -JSON http://192.168.0.1/ps4.json -JSONFile /var/www/html/ps4.json so you don't have to spin up a HTTP server at all. What do you think?

marcussacana commented 4 weeks ago

The PS4 payload can't start the download only with the JSON because it depends of some info that the DPI automatically take from the PKG, that's the job of that "PKG Info Server" in the flowchart. So even if the DPI support send the json manifest directly, the download will not be able to start without the "PKG Info Server" job. I don't think is the best way stop the HTTP server to run the PKG Info Server because it will interrupt the download for the user that tries to send a second download. If you firewall is in your system and not the router I would hint you to just let the DPI open any port, the tool is open source and if is a trust problem is possible just keep a fork. That said I will consider option to change the ports, but not sure of what to do. I would like more let change in the Settings.ini instead cmd line if it is the case as well.

Anuskuss commented 3 weeks ago

I don't think is the best way stop the HTTP server to run the PKG Info Server because it will interrupt the download for the user that tries to send a second download.

Isn't that only for situations where the PKG is served from DPI though? I send a link to my own HTTP server hosting the PKG so I wouldn't need that. I just find it ugly to open 2 ports for a single application (reminds me of FTP's ugly design) but if you can't make it work I'll deal with it.

If you firewall is in your system and not the router I would hint you to just let the DPI open any port

I don't think that possible, at least not with iptables.

if is a trust problem is possible just keep a fork.

It's not that I don't trust DPI, I don't trust any application period. But I can make an exception for DPI, and open 1 (or 2) port(s) that just DPI is allowed to use. But I gotta know which port to open so a -Port argument would be needed.

I would like more let change in the Settings.ini instead cmd line

I don't like the idea of Settings.ini; I'll only ever need -PS4, -Port and <url>. I don't even want to specify -Server and rather let DPI figure it out itself (through the PS4 argument, e.g. ip route show to match 192.168.0.2). I'll call DPI from my PS4 through PHP and Settings.ini would make that needlessly complicated (I would have to edit Settings.ini from PHP instead of just calling the executable).

marcussacana commented 3 weeks ago

I will analyze the possibility.