• just_another_person@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    2
    ·
    3 days ago

    I don’t even know where to begin with this 😂

    You had better alert the Internet at large and the developers of the apps being discussed here to let them that the very product they build is impossible then.

    Oh…wait: https://reintech.io/blog/using-node-js-to-access-remote-database

    A very basic example on how to do the very thing you said is not possible you say? While you’re at it, you better go alert Zoom, Google, Microsoft, and anyone else with a WebRTC app that they aren’t allowed to make connections to other things from the browser. It’s totally against the rules and impossible.

    🤣

    • Markaos@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      3 days ago

      Node.js is a web server. It doesn’t run in a browser, therefore doesn’t deal with the browser sandbox. That should answer your first dig.

      For the second part, WebRTC is a standard that allows two WebRTC peers to communicate. You can’t use WebRTC to open an arbitrary TCP or UDP stream to for example a database, unless said database decides to implement a WebRTC peer support.

      • just_another_person@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        3 days ago

        Friend, I’ve literally linked the DBGate repo. You can see yourself there is no server component running, and it’s all in browser. It’s literally called “web-based”. Have a look here: https://docs.dbgate.io/web-app-config/

        So in your world, you imagine that if you run this project, there is a server running…somewhere, and then it’s forwarding all requests from the browser to this server, and the server is making the connections to the DB endpoint? Lolzzzz 🤣🤣🤣

        https://github.com/dbgate/dbgate/tree/master/plugins/dbgate-plugin-postgres

        • Markaos@discuss.tchncs.de
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 days ago

          All right, I had some spare time today, so I went and installed this thing.

          My setup is a bit more complex than the minimum necessary, but that’s because I’m using an already existing Postgres database instead of installing a new one on my computer. It is as follows: Postgres running on a mini PC on my local network (192.168.2.199:5432), a browser running on my main computer, and a Debian VM for DBgate with two NICs - one is the default NAT interface (I’m too lazy to configure proper bridging / routing) and the second is a virtual bridge, testbr. On testbr, the host OS is 192.168.123.1/24, and the guest is 192.168.123.2/24.

          I installed DBgate on the VM using NPM - npm install -g dbgate-serve, as specified in the documentation. Then I ran it using simply dbgate-serve, then connected to it from a browser running on my host OS as http://192.168.123.2:3000/. That works fine.

          Then I added my Postgres DB through the web interface (to be verbose, I entered 192.168.2.199 as the IP address), created a table and inserted some dummy data. Then I wanted to do the next step, which is to block outgoing connections to port 5432 from the VM, but I noticed something very strange, given that DBgate obviously doesn’t use the server as a backend to do the actual DB connection: this was in the server log

          {"pid":7012,"caller":"databaseConnections","conid":"24d95082-ca6a-4dac-aa28-f3121bfc508d","database":"dbgate","sql":"INSERT INTO \"public\".\"dbgate_test\" (\"text\") VALUES ('haha');\nINSERT INTO \"public\".\"dbgate_test\" (\"text\") VALUES ('hehe');\n","level":30,"msg":"Processing script","time":1744395411096}
          

          But it would be ridiculous to even suggest that the connection is relayed through the server, so it is probably some kind of telemetry. Makes sense.

          Anyway, I went ahead and added the rules on the VM nft add table ip filter, nft 'add chain ip filter output { type filter hook output priority 0; tcp dport 5432 drop; }', and you wouldn’t believe what happened next… The DBgate tab can no longer load data from the database. I can reload DBgate itself without any issues, and I can connect to the database from the same computer using psql and DataGrip just fine, but for some reason it seems to be affected by the fact that its server (which is only serving the HTML/JS files and doing nothing else, as you said) cannot connect to Postgres.

          Weird how that works, huh?

        • priapus@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          3 days ago

          there is no server component running

          What the hell are you talking about? Just look at the Dockerfile.

          CMD [“node”, “server.js”]

          You think that line isn’t running a server?

          Thr repo makes it very obvious that it runs a server that the webgui connects to. Its fine if you dont know shit but dont be a dick while being stupid.

        • jogai_san@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          2
          arrow-down
          1
          ·
          3 days ago

          Friend, I’ve literally linked the DBGate repo. You can see yourself there is no server component running

          Yet you ignore I pointed to the api component in the repo…