Bridging/cloning Matrix Synapse server in intranet with server in internet - matrix-synapse

I would want to bridge or clone two Matrix servers, one located in a intranet and the other in internet. Intranet can access internet (with not infrequent cuts) but cannot be accessed from internet. Both server are connected by a VPN so they can communicate each other.
Many of the users connect from the intranet and other from internet. The goal is that the intranet users can connect without going to internet, because the internet connection is metered and long periods without no internet connection are frequent. Ideally both servers would act as a unique Matrix server, so intranet users don't need to create two accounts. Servers should synchronize events whenever the internet connection is working.
I suppose this is not feasible without a quite big chunk of code. My doubt is which pieces of software should I create. Should I develop a bridge? Perhaps a bot approach or account linking? Any more suitable solution I am not aware of?

Related

Offline mode for SAAS multitenant Web Application

We have SAAS multitenant Web Application for hotel reservation and Key issuing, that can work both in Online and Offline modes.
The user needs limited features like making the reservation and issuing keys for Guest through the webapp, in case he is offline and full feature access when he becomes online again. I thought of the following options:
Make the hotel host a server locally that will replicate event from the cloud database to the local
Create a light version of limited feature of the App to host locally with the replicate Database
Create a shortcut URL to local computer but Only allow access to the local web app when Internet connection down
Save all message(CRUD from feature table) to a Queue in the local server(Linux box)
When internet is back, send these to the cloud for data Sync
This seems like a good solution since it is cover the scenario and it integrates a local server, relational datastore and a queuing messages to send to cloud
Very easy solution when it come to mobile , but since this is a web, we seems to be limited by available technics.
Has anyone worked/working on such an application. Ideas welcome.

Can my friend's pc connect to my PostgreSQL? If yes, how?

By far NONE answered my question, so i'm stuck here...
Basically i made a program (it's connected to my PostgreSQL database) which, depending on the user input, it will change tables contents in the database. It's a sort of Register/Login sistem. (click here if you want to see the script). When i run it on my pc (Windows 10 x64) it works like a charm. But when a friend of mine (Windows 10 x64) tries to run it (on a different network) it gives him this error:
Could not connect to server: Connection refused
Is the server running on host “192.168.1.113” and accepting TCP/IP connections on port 5432?
(if it can help you, i tried MySQL too, but i got the same result... my friend cannot access to my database!)
So, I was asking my self "Is it even possible allow other devices to access my database from other networks? If yes, how can I do it?"
192.168.*.* is for local network addresses. You would not expect it to be reachable from another network. You would have to figure out what your real address is. For example, by going to https://whatismyipaddress.com/ or just Googling "what is my IP address".
Then you have the question of how often that address changes (which is up to your ISP) and how to get the connection past your home router, which will probably either block it, or at least not route it to your database server, without special configuration to do port-forwarding. This is a basic networking task and at the moment is not specific to PostgreSQL.
Your ISP may also block the connection, as hosting servers on your standard home ISP plan is likely against the terms of service. Although most of them allow it if the traffic never comes to their attention due to high usage or due to abuse complaints.
I'd advise against that, we use databases to store metadata, text based data, data that you need to run queries upon, for storing images what services like instagram, pinterest do-- is they store images on services like s3 which are inexpensive, [because databases are extremely expensive]. Plust the amount of images generate per second, should you receive that amount of traffic would be astronomical.
What they do is they store the images on s3-- it's like your hard disk, but hosted on the internet, and then store the path in the database, and when someone asks for that image, we serve it from s3.

What possibilities are there to connect to a postgres database

I was wondering: What possibilities are there to connect to a postgres database?
I know off top of my head that there are at least two possibilities.
The first possibility is a brute one: Open a port and let users anonymously make changes.
The second way is to create a website that communicates with postgres with use of SQL commands.
I couldn't find any more options on the internet so I was wondering if there are any. I'm curious if other options exist. Because maybe one of those options is the best solution to communicate with postgres via the internet.
This is more of a networking/security type question, I think.
You can have your database fully exposed to the internet which is generally a bad idea unless you are just screwing around for fun and don't mind it being completely hosed at some point. I assume this is what you mean by option 1 of your question.
You can have a firewall in front that only exposes it for certain incoming IP's. This is a little better, but still feels a little exposed for a database, especially if there is sensitive data on it.
If you have a limited number of folks that need to interact with the DB, you can have it completely firewalled, but allow SSH connections to the internal network (possibly the same server) and then port forward through the ssh tunnel. This is generally the best way if you need to give full DB access to folks that are external to the DB's network since SSH can be made much more secure than a direct DB connection by using a public/private keypair for each incoming connection. You can also only allow SSH from specific IP's through your firewall as an added level of security.
Similar to SSH, you could stand up a VPN and allow access to the LAN upon which the DB sits and control access through the VPN.
If you have a wider audience, you can allow no external access to the database (except for you or a DBA/Administrator type person through SSH tunneling or VPN). Then build access through a website where communication to the DB is done on the server side scripting (php, node.js, rails, .net, what-have-you). This is the usual website set up that every site with a database behind it uses. I assume that's what you mean in your option 2 of your question.

In-house iphone app database connection

I am going to build an in-house application within a company. I was told that the data sample is located on the DMZ network, so how can I connect to this? The main task is going to surface data and display it. I have no idea about DMZ network and is there sort of API available to achieve this?
There is not any API for direct connection to Database(as per my knowledge)
create a local web-service, which will accessible only in DMZ network.
User those web-methods to communicate with database.
As the access of web-service is within DMZ, user will have access of data within DMZ network

How do BitTorrents connect with eachother?

I was just downloading a new distro of linux using uTorrent, and started to wonder how uTorrent (and other bittorrents) send files to eachother through NAT routers? They obviously use the trackers to get introduced, but how do they pass info to eachother?
Is there a whitepaper on this? I couldn't find one :/
Thanks
Most of the time, they don't. I have a restricted network, and every time I run my torrent program it warns me that some of the ports/functionality required is not available to me.
If one party has a restricted network and another has an open network, the restricted client will always connect to the open client. If you have two restricted clients they will not be able to connect to each other. The reason it works at all is that most (enough) of the people on the torrent network do have some kind of port forwarding or UPNP (universal plug and play) to facilitate this.
Torrent clients work on the basis of what are known as Distributed Hash Tables. They start off with a set of known roots, and branch out looking for other, connected nodes (i.e., neighbours). Establish connections to them, and keep this up, up to a set limit. Since the client is initiating the connection, all the remote has to do is feed the data back, and you get it through the NAT just fine. It's how network traffic works.