OPROSVOs / frensync

The client userscript to sync additional fields on 4chan
Other
5 stars 1 forks source link

Backup server #2

Open iBoonie opened 2 years ago

iBoonie commented 2 years ago

I saw over on /g/ that NS exploded a while ago, so I implemented my own server NamesyncRedux (of course I only found out about frensync after I finished my implementation). Everything is 1:1 with the original NS, and I have a server up and running at https://www.nsredux.com/namesync if you want a backup. I do not have any of the color stuff you added, but I could do that easy enough.

OPROSVOs commented 2 years ago

I didn't think it made such large waves. Of course i'm interested. The main idea was to have the server side shared over 2-3 servers to be more reliable and an open implementation. And my implementation is not as elegant but compatible and hopefully reliable.

I've only added the color support to get the everything known better and test a few things and no color is the default. Also the idea was to merge all responses like if the original is up and provides a secure trip, that one is preferred over all other servers. Likewise with other features. But i wait till its back up because testing right now is impossible.

One problem i've found was that the first request to sp.php already triggered the flood protection / the response was HTTP 429. I also have a simple flood protection running, which writes into the error log. And fail2ban blocks out everything major after a few tries. Changing the server for testing is as easy as changing the local storage value frensyncServerlist to {"server":[{"namesync.net":{"name":"namesync original","sp":true,"qp":true,"retry":3,"timeout":15,"prio":["t"]}},{"m8q16hakamiuv8ch.myfritz.net":{"name":"frensync backup","sp":true,"qp":true,"retry":10,"timeout":30}},{"www.nsredux.com":{"name":"NSredux","sp":true,"qp":true,"retry":10,"timeout":30}}],"revisit":259200,"api":1}

Another problem is that the server response to an non existing thread is an empty string but should be an empty JSON set [] like the original. I used that to check wether the original is really up and working.

And i've tried to keep the amount of saved data as minimal as possible. Another way would be having a table where you'd map all user fields to an ID and another table mapping this ID to an thread/post. That would be more efficient except for deleting but i havent had the time for it.

Do you have any contact info / messenger?

iBoonie commented 2 years ago

original is up and provides a secure trip

One will never be able to match NS's secure trip unless the owner shares how they implemented it, so I wouldn't worry about this to much.

I've only added the color support to get the everything known better

Once you are happy with how you want to set colors, ill match it in mine.

sp.php already triggered the flood protection

Interesting, that shouldn't have triggered unless you tried post 2 times in the last 30 seconds. I could just increase it to 5 in 60 seconds.

I also have a simple flood protection running, which writes into the error log

I could add this easily enough to match yours. I also have everything behind cloudflare so that should limit mass requests.

empty string but should be an empty JSON set []

Oops, you are correct, it also didn't like me setting a 204 header. Its been fixed.

And i've tried to keep the amount of saved data as minimal as possible.

If it becomes a problem it would be easy enough to change, I have it set to purge data every day and remove data older than 7, so the table shouldnt be to big.

OPROSVOs commented 2 years ago

Yeah, the original is up but has an SQL error. And the secure trip salt is the secret sauce. But i wouldn't worry about that because every other site (like 2ch) was not compatible.

The color support shouldn't change much and its just an color amount as ca (null, 0 to 50) and color hue as ch (null, 0 to 360) as smallint with some range checks to keep people from breaking it. That prevents like dark gray on tomorrow or light blue on burichan. But its no priority right now.

It will be interesting, if both servers respond to the client. If there is any difference, the client will have a race condition after every new post where the first to respond will cause a DOM change and the second will overwrite that. That is fine for as long as it is the same. I will improve the handling a bit next weekend.

And i have this running with some other services on a fair machine here connected via fibre. But nothing beats cloudflare. That works if there is only a handful of people that don't ddos. Atleast fail2ban blocks it off via the iptables. It also supports blocking the user via cloudflare so the traffic does not reach the server.

I just don't want to start/deal with the data protection law here. If you dont save personal information, you're usually good to go but the IP counts as that. Plus right now i get like 20k entries every 15 days from a dozen of people. I added a chronjob which wipes the table except for the last 300 posts every month.

Just keep in mind that there are active threads all around the clock and if you wipe everything, these threads get cut off in the middle.

I've added the server to the master server list. Thanks.

iBoonie commented 2 years ago

If the color implementation isn't going to change, ill add it to mine tomorrow sometime along with some other changes. I have IP's hashed, so they aren't plaintxt, not sure if that counts as personal info. My cron doesn't wipe everything, just stuff older than a week. I could probably limit it to 3 days.

OPROSVOs commented 2 years ago

Thanks.

Right now it looks like it works out of the box. I'm no lawyer but hashed IPs should be fine if you can't recover the IP.

And that should also be fine. I've seen some threads on /trash/ that ran for 20+ days but there is also native name support on that board.

iBoonie commented 2 years ago

hashed IPs should be fine

Im not worried.

20+ days

Damn, well that's something. Currently I fetch all the forced anon boards from the API and build a board list from that. I may push it to 30 day retention incase they ever force anon on /trash/ again.

If you want to limit dataflow as much as you can, I would not store color/hue in the DB if 0, just check if they are null on the client (unless you already do this, I havent checked yet)

nokosage commented 2 years ago

This is very cool. I am very happy to see others taking initiative here!

I apologize for NS's server being so unreliable for the past few months. I do not seem to have the time to solve technical debt within its system at the moment by myself, and I have been away from home for the past month. Of course it would explode on me the day I leave! Hah. My poor down detector has been sending me notifications and I wasn't able to see them.

That said... It's very interesting how many people rely on it after all these years. I would be willing to work with you if you need any assistance. There's a lot on the NameSync server-side that could be open sourced or massaged into something sharable which could be useful. I love the idea of redundancy here. NS used to have an AWS VM backup that would kick in if the down detecter triggered, but that was several providers ago. A fair amount has changed in the last decade!

OPROSVOs commented 2 years ago

Thanks. I quickly threw something together during the holidays after it was down for weeks and thats the result. I fixed some minor things added some ideas and got two new minor visual bugs. Some guy in the thread had the idea to continue with a new name and implement new things but the principle is the same.

I think its normal to have some down time, if something is running over such a long time. Many many thanks for keeping it running the past years! Right now i have two machines idling here on a beefy connection and the most traffic comes from bots trying to break in. Got apparmor running if there is a flaw in the code and fail2ban to get rid of bots plus a quick way to load a backup and a flood protection. Nsredux is running behind cloudflare which deals with any potential ddos. Its interesting that your approach was going for server side redundancy rather than client side. In the end if the repo is used for updating and the accounts are dead, the extension dies because of the update process. If the code base is atleast open, others can start a new and not everything is lost but still the users would have to migrate over. Thats why i asked others to join in as maintainer and have a json file that keeps track of all active servers. The client queries this at a set interval.

The multiserver implementation right now is just a best effort where the client posts to all servers (downside is the client has to trust every server) and queries all again. Problems come up if two servers don't argree on fields (ends in a XHR race condition). If one server has an partial complete query, all data is merged in the end. That way the databases don't have to be in sync and everything can run completely independant. We got most features running from just looking at the server interface. NsRedux doesn't support the catalog lookup yet and my implementation doesn't have the "clear sync history" functionality yet. Edit: the "time" in qp is missing and there is something causing the namesync server to error out when posting to sp.php (maybe the two additional fields ca/ch or the requested-with). But both servers delete the data within a month anyway and the rm works. And i implemented color support at request and to get an better understanding of the update code it is just two numbers added on the server side. Getting the tripcode working was a challenge and secure tripcodes require a salt shared across the servers - pushing this to github would defeat the purpose sadly. I'm not sure how NS did implement this since 4chan has its own salt on other boards. There are also some that use extensions on top like persona plus / oneechan which i added into a complete setup guide. And currently only namesync is on some adblock filter list while the other master servers dont face that problem.

There are mainly the furry threads, some draw threads and some threads with consistancy on /b/ that currently use it since /trash/ got support for names now. A lot has changed the past decade but interestingly these threads have sparked and there are constantly new users. It would be great if we could pull something together.