Server Help

Misc User Apps - ssbilling2 for linux (ported)

Doc Flabby - Tue Oct 16, 2007 8:20 am
Post subject: ssbilling2 for linux (ported)
Linux port of "SubSpace Billing Server 2 Release 11j" by CatId

(still compiles in windows icon_surprised.gif using dev-c++)

Now you can run a udp biller on linux.

An entire ASSS + Biller setup without wine or windows - oh my!

Only tested on debian linux etch. (probably has a few bugs)

Known Issues:

Netban text can only be changed by editing the subbill.ini (in game doesnt work)

Difficult to compile. See the makefile i enclose. Because CatId used some horrible non-standard c++ which i only vaguly understand it chokes on it if you compile with gcc > 4. Therefore you must compile using gcc 3.4. Then link using your normal g++ lib otherwise pthreads won't work.

I've included the binary.

EDIT: PS don't even think about turning encryption on. 20+ lines of assembly is to try and port was much for me tongue.gif You're welcome to have a go though.

Please check further down the page for an updated version that works with gcc 4.3
L.C. - Mon Feb 04, 2008 4:35 pm
Post subject:
FreeBSD 6.1
Quote:
ELF binary type "0" not known.
-bash: ./ssbilling2-linux: cannot execute binary file


All files CHMODed with +x.
BDwinsAlt - Mon Feb 04, 2008 9:52 pm
Post subject:
Runs fine on Ubuntu Linux. FreeBSD is different from Linux, so that's probably why. I bet you could tweak something to make it work. Try compiling it using FreeBSD.
Mine GO BOOM - Tue Feb 05, 2008 4:17 am
Post subject:
Or you can use Linux Binary Compatibility on FreeBSD.
Doc Flabby - Tue Feb 05, 2008 7:01 am
Post subject:
i suggest recompiling for your platform, i have included the makefiles..

It would simpley be a matter of typing

"make" in the source directory and seeing if it worked.
L.C. - Thu Feb 07, 2008 6:08 pm
Post subject:
I could not recompile this (using GCC 3.4.4), thus could not launch it.

I tried compiling it with both the 'make' and 'gmake' commands.
BDwinsAlt - Thu Feb 07, 2008 8:35 pm
Post subject:
Hmm. Is there any output that you could copy and paste when you try to compile. When I type make -v I get:
GNU Make 3.81
L.C. - Thu Feb 07, 2008 11:24 pm
Post subject:
Code: Show/Hide

-(qwerty@shadow)-(08:22:48)-
-(~)- cd subspace
-(qwerty@shadow)-(08:22:52)-
-(~/subspace)- cd ssbilling2
-(qwerty@shadow)-(08:22:54)-
-(~/subspace/ssbilling2)- make -v
make: don't know how to make all-before. Stop
-(qwerty@shadow)-(08:22:57)-
-(~/subspace/ssbilling2)- make
make: don't know how to make all-before. Stop
-(qwerty@shadow)-(08:23:00)-
-(~/subspace/ssbilling2)- make --version
make: illegal option -- -
usage: make [-BPSXeiknqrstv] [-C directory] [-D variable]
        [-d flags] [-E variable] [-f makefile] [-I directory]
        [-j max_jobs] [-m directory] [-V variable]
        [variable=value] [target ...]
-(qwerty@shadow)-(08:23:05)-
-(~/subspace/ssbilling2)- gmake --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-portbld-freebsd6.1
-(qwerty@shadow)-(08:23:17)-
-(~/subspace/ssbilling2)-
-(qwerty@shadow)-(08:23:27)-
-(~/subspace/ssbilling2)- gmake
gcc-3.4 -c main.cpp -o main.o   -D_REENTRANT
gmake: gcc-3.4: Command not found
gmake: *** [main.o] Error 127
-(qwerty@shadow)-(08:24:20)-
-(~/subspace/ssbilling2)-

Doc Flabby - Fri Feb 08, 2008 10:01 am
Post subject:
Quote:

Code: Show/Hide

gmake: gcc-3.4: Command not found



You need to install gcc-3.4 in order to compile it. As i meantion in my first post, i had to do some wierd things to get it to compile. (i don't know much c++/c so there may have been a better way of doing it, but that task is for someone else tongue.gif )
BDwinsAlt - Fri Feb 08, 2008 5:41 pm
Post subject:
All I had to do was type make. Look in your package manager (if there is one) and download it. I have it installed on my computer already.
L.C. - Sat Feb 09, 2008 2:45 pm
Post subject:
Gave up on FreeBSD. Works fine on Linux and is functional. Took me a while to figure out that when I closed my console it also ended the ssbilling2 process.

I don't think I'll be running a Public Biller again until a decent Linux-based biller that can handle this or cluster with SSC (or something) would be possible.
Doc Flabby - Sun Feb 10, 2008 4:08 pm
Post subject:
You need to run it as a background process to get it to stay open after you close the terminal. Use the &. Similarly with the directory server.

Code: Show/Hide

./ssbilling2-linux&


Glad its working for everyone icon_smile.gif
L.C. - Mon Feb 11, 2008 1:43 pm
Post subject:
Bleh. I just opened a screen and ran it. I think I'm doing that for the ddirserv, but I noticed that the ddirserv will still continue running regardless of adding the & to it.

If you add & to the end of any binary when executing it, it makes that binary run as a background?
Doc Flabby - Mon Feb 11, 2008 2:01 pm
Post subject:
The dirserver is coded alot nicer (based on mervbot) than the biller, which is probably why it works wthout the &

L.C. wrote:

If you add & to the end of any binary when executing it, it makes that binary run as a background?


yes
L.C. - Mon Feb 11, 2008 7:42 pm
Post subject:
I did notice one minor bug or inconsistency with the mirroring function though. Does it only check the first IP/address unless the first given one doesn't work?

Code: Show/Hide
[Core]
PacketSilenceLimit=2000
MaxReliableInTransit=3
ChunkSize=496
ClusterMode=0
MaxHosts=20

[CPU]
SlowIteration=300
IterationSleepTime=5

[Zone]
SweepTime=500
DropLimit=10
ReclaimDelay=24
InitialHighPing=300

[Directory]
IP=ssdir.playsubspace.com dir.cz.sshq.net sscentral.sscuservers.net
DownloadTime=5
StatsFile=stats.txt
StatsWriteMinutes=5


That's what I have.

EDIT :: Running ./ddirserv& didn't make it run in the background. It stopped as soon as I closed Putty. So I reconnected and started a screen to run it. Works fine for me if just use screen. sa_tongue.gif
Doc Flabby - Tue Feb 12, 2008 6:20 am
Post subject:
L.C. wrote:
I did notice one minor bug or inconsistency with the mirroring function though. Does it only check the first IP/address unless the first given one doesn't work?

No idea, might do that in the orginal version.
L.C. wrote:
EDIT :: Running ./ddirserv& didn't make it run in the background. It stopped as soon as I closed Putty. So I reconnected and started a screen to run it. Works fine for me if just use screen. sa_tongue.gif


You need to type "exit" first (logoff your session) then close putty.
Goldeye - Tue Feb 12, 2008 9:34 pm
Post subject:
./ssbilling2& will normally not run once you logout of the shell.
You need to make it a daemon to do that.
Google daemonize.c, someone put it together so you don't have to write it yourself.
CypherJF - Tue Feb 12, 2008 11:14 pm
Post subject:
I don't know about this app but even with my biller I have to do what doc said; type "exit" before you close putty.
SSLamby - Fri Aug 29, 2008 6:08 am
Post subject:
I have improved it a little bit to at least compile with gcc 4.3.1.

Basically what I did was to:
> #include <algorithm> // in linkedlist.h to solve the std::reverse error.
> lift out the CallRecvThread and CallResendThread from it's class, in order to make them accessible as pointers for pthread.
>Add a bunch of prototypes for the packet handler functions (HandleSpecial etc.) in both rpc.h and declares.h
>Fixing some warningns due to missing const keywords.

I hope this did not introduce or uncover any new bugs, it appears to work but I have no reference to compare with.

[edit, removed binaries from tarball]
Doc Flabby - Fri Aug 29, 2008 6:38 am
Post subject:
Thanks for your contribution. Hopefully someone will find it useful!

The original windows (reference) source is here: http://www.mervbot.com/files/subbill.zip
L.C. - Sun Aug 31, 2008 11:30 am
Post subject:
Quote:
EDIT :: Running ./ddirserv& didn't make it run in the background. It stopped as soon as I closed Putty. So I reconnected and started a screen to run it. Works fine for me if just use screen. sa_tongue.gif
Obsolete now. :\ I realized that when I would launch a program like that, the visual appearance of the things in Putty wouldn't change, but I could freely go ahead and enter in a command and it would work just fine. I use ./program& and then usually do CTRL+A+D or some screen switch to detach from the screen.
CypherJF - Sun Aug 31, 2008 3:43 pm
Post subject:
I found out using the command "nohup cmd &" does wonders. See the man page for nohup.
fatrolls - Thu Jul 25, 2013 12:19 am
Post subject: problem with this biller
I tried running this on centos runs properly but when it's connecting to ASSS using ssc_billing i get the following errors..

Invalid login from..?

if I try to connect with just billing without ssc_billing that gives me connection refused error.

This is how the biller looks with ssc_billing enabled

What must i do.


fatrolls - Thu Jul 25, 2013 6:29 pm
Post subject:
Fixed

in modules.conf pick
Code: Show/Hide

ssc_billing
and make
billing to
;billing


then in global.conf set
Under
Code: Show/Hide

[Billing]
ServerID=27015
GroupId=1
ScoreID=27015

SpaceHiker - Sat Apr 05, 2014 2:07 pm
Post subject:
For me, this compiles and executes without errors or warnings, creates the .dat files, allows zone servers to connect, and "L" shows the host list.

But, it does not allow users to log in (failed to connect to server).

Any ideas?

my gcc is 4.4.6 and my distro is amazon's CentOS variant (Amazon Linux AMI release 2013.03).
fatrolls - Sun Apr 06, 2014 9:19 am
Post subject:
yes SpaceHiker your issue is pretty simple I also had the same problem..

The person who ported this into linux did a very poor job he had a mindset like this

This works on 32bit cpu I need to port it to 64bit cpu and Linux what should do I? Okay first let me replace all the int's with long's lol sa_tongue.gif

That's why when you connect nothing happens. Now we are at a problem not knowing what was really a long before and what was really a int before.

Going crazy changing all the long's back into int's is worse you might break something.

But changing some common mistakes there is only 6 to fix it.

Biggest mistakes are with the packet readers

Code: Show/Hide

long GetLong(BYTE * Message, const SHORT Offset)
{   // Get a long from a char *
   return *(long*)&(Message[Offset]);
}


should be

Code: Show/Hide

Uint32 GetLong(BYTE * Message, const SHORT Offset)
{   // Get a long from a char *
   return *(Uint32*)&(Message[Offset]);
}


Second one looks like this

Code: Show/Hide

Uint32 GetLong(char * Message, const SHORT Offset)
{   // Get a long from a char *
   return *(Uint32*)&(Message[Offset]);
}


it should only read 4 bytes from packet stream not 8 even though it's called GetLong it really means get unsigned int

Now all those possible error messages will now also use this GetLong so the linkedlist will have errors now because it doesn't support unsigned int

So the final 3 errors will involve adding code to linkedlist (although it never probably uses the long version in linkedlist and you could just rename it to Uint32/DWORD still safer to just create a new ones).

Under

Code: Show/Hide

   void operator=(const int);                  // l-string = r-int;


add
Code: Show/Hide

   void operator=(const unsigned int);                  // l-string = r-uint;


Under

Code: Show/Hide

   void operator+=(const int);                  // l-string += r-int;


add

Code: Show/Hide

   void operator+=(const unsigned int);                  // l-string += r-uint;


Under

Code: Show/Hide

   _string operator+(const int);               // l-string + r-int;


add

Code: Show/Hide

   _string operator+(const unsigned int);               // l-string + r-uint;


Now comes filling in the codes just copy/paste the int version right under it and change to unsigned int

Like so

Code: Show/Hide

void _string::operator=(const unsigned int Number)
{
   char Message[50];
   itoa(Number, Message, 10);

   delete Text;

   Text = new char[ (Length = strlen(Message)) + 1 ];
   memcpy(Text, Message, Length + 1);
}


Code: Show/Hide

void _string::operator+=(const unsigned int Number)
{
   char Message[50];
   itoa(Number, Message, 10);

   char * new_pointer;

   new_pointer = new char[ (Length + strlen(Message)) + 1 ];
   memcpy(new_pointer, Text, Length);
   memcpy(&new_pointer[Length], Message, strlen(Message) + 1);

   delete Text;

   Text    =   new_pointer;
   Length   +=   strlen(Message);
}


Code: Show/Hide

_string _string::operator+(const unsigned int Number)
{
   char Message[50];
   itoa(Number, Message, 10);

   _string S;

   S.Text = new char[ (S.Length = Length + strlen(Message)) + 1 ];
   memcpy(S.Text, Text, Length);
   memcpy(&S.Text[Length], Message, strlen(Message) + 1);

   return S;
}


That's it now it should work.. I would change all the long's that should be uint32 or just int32 and it would probably make the biller take twice as less memory.

But hey it works good enough for me.. plus changing all those long's to uint32's will corrupt the saved user entries database not like it's compatible with SCOREMAN anymore.

Another fix to fix negative ports (this is only for GUI display it will work without this fix).

Replace all short Port with SHORT Port

since typedef unsigned short SHORT; it would make it unsigned too.

This is okay for now, But I recommend porting catid's ssbilling2 again to linux without making any of these find/replace mistakes would fix more issues which are unknown right now.

Another fix I just added to support more users which SSBilling2 considers illegal/invalid clients.

Code: Show/Hide

bool InvalidMachineID(long MachineID)
{
   /*if (MachineID == 101) return false;

   if (MachineID < 0) return true;

   if (MachineID < 2000) return true;
   */
   return false;
}

fatrolls - Mon Apr 07, 2014 7:07 am
Post subject:
Converted the ASM in the ssbilling2-linux into C code, now Comms:EncryptMode=1 works without any problems.

Here is the code if anyone is interested.

Code: Show/Hide

#ifndef ENCRYPTION_H
#define ENCRYPTION_H
#endif


// Packet encryption

void Host::InitializeEncryption(unsigned int Key)
{
   if (SentKey == Key)
   {
      SSEncrTable.SSKey = 0;
      return;
   }

   SSEncrTable.SSKey = Key;

   // Do the ASM thing (Assembly rips provided by Coconut Emulator)
   // Initialize calculations
   
   //It's a regular pseudo-random number with +123 extra -fatrolls
   int SKey = (int)Key;
   int counter = 0;
   int remaining = 260; //sizeof(SSBuf)  = 520 / 2 = 260.
   do
   {
      SKey = 16807 * (SKey % 127773) - 2836 * (SKey / 127773) + 123;
      if ( SKey <= 0 )
         SKey += 2147483647;
      SSEncrTable.SSBuf[counter] = (SKey & 0xFF);
      SSEncrTable.SSBuf[counter+1] = (SKey >> 8) & 0xFF;
      counter += 2;
      --remaining;
   }
   while (remaining);
}

void Host::Encrypt(char * Message, unsigned short Length)
{
   if (SSEncrTable.SSKey == 0) return;

   unsigned int IV = SSEncrTable.SSKey;
   char buffer[520];
   memset(buffer, 0, 520);

   if (Message[0] == 0)
      memcpy(buffer, &Message[2], Length - 2);
   else
      memcpy(buffer, &Message[1], Length - 1);

   for (unsigned short Counter = 0; Counter < 520; Counter += 4)
   {
      IV = GetLong(buffer, Counter) ^ GetLong(SSEncrTable.SSBuf, Counter) ^ IV;

      *(unsigned int*)&buffer[Counter] = IV;
   }

   if (Message[0] == 0)
      memcpy(&Message[2], buffer, Length - 2);
   else
      memcpy(&Message[1], buffer, Length - 1);
}

void Host::Decrypt(char * Message, unsigned short Length)
{
   if (SSEncrTable.SSKey == 0) return;

   unsigned int IV = SSEncrTable.SSKey;
   unsigned int ESI;
   unsigned int EDX;
   char buffer[520];
   memset(buffer, 0, 520);

   if (Message[0] == 0)
      memcpy(buffer, &Message[2], Length - 2);
   else
      memcpy(buffer, &Message[1], Length - 1);

   for (unsigned short Counter = 0; Counter < 520; Counter += 4)
   {
      EDX = GetLong(buffer, Counter);
      ESI = GetLong(SSEncrTable.SSBuf, Counter) ^ IV ^ EDX;
      IV = EDX;
      *(unsigned int*)&buffer[Counter] = ESI;
   }

   if (Message[0] == 0)
      memcpy(&Message[2], buffer, Length - 2);
   else
      memcpy(&Message[1], buffer, Length - 1);
}


// One-way encryption algorithms

void HashPassword(char * Password)
{
   size_t StrLen = strlen((char*)Password);
   unsigned short Factor = 0;
   char Char;
   size_t L = 0;
   for (L = 0; L < StrLen; L++)
      Factor ^= Password[L];

   for (L = 0; L < StrLen; L++)
   {
      Char = (Password[L] ^= Factor);
      Factor = (Factor ^ (Char << (Char & 3))) & 255;
      if (Password[L] == 0)
         Password[L] = 0xED;
   }
}

unsigned long HashModemInfo(char * Info)
{
    unsigned long h = 0, g;

   for (short i = 0; i < 608; i++)
    {
        h = ( h << 4 ) + *Info++;
        if ( g = h & 0xF0000000 )
            h ^= g >> 24;
        h &= ~g;
    }

    return h;
}

Doc Flabby - Mon Apr 07, 2014 2:16 pm
Post subject:
Nice to see someone has taken an interest in this icon_smile.gif Sorry for all the bugs I don't think i was worried too much abut 64-bit in 2007 biggrin.gif
fatrolls - Mon Apr 07, 2014 6:29 pm
Post subject:
Here is my port I pretty much copied pasted stuff from your port but I used a clean catid ssbilling2 from http://mervbot.com/files/ssb2confess.rar made by confess+. Although my version can't compile on windows like yours can, it's probably not to hard to fix up to work for windows. It saves users and EncryptMode=1 works. Haven't had it crash for 2 days now but I compile it with -g flag so if it crashes I could see the line number where it crashed.


Compiles with no warnings or errors on my CentOS 6 Linux but I use a old version of g++ because new versions are too strict.

Here is the compile log

Code: Show/Hide

[root@test biller]# make all
[root@test biller]# g++ -c main.cpp -o main.o   -D_REENTRANT -m64 -g
[root@test biller]# g++ main.o  -o "ssbilling2-linux" -lpthread -m64 -g
[root@test biller]#


I attached it it's also beautified (no tabs) / 4 spaces / always close with bracket.
SpaceHiker - Sun Apr 13, 2014 5:37 pm
Post subject:
This is awesome, thanks!
CypherJF - Sun Apr 13, 2014 7:15 pm
Post subject:
For those interested, I've posted ssbilling from Confess (2.0c) to bitbucket.

https://bitbucket.org/cypherjf/ssbilling-server/overview

I'm planning to add in my future tweaks to it - but it may be helpful to start merging some of this together?
SpaceHiker - Thu Apr 17, 2014 11:36 pm
Post subject:
fatrolls, can you tell me your gcc --version and your g++ --version?

Thanks
Cheese - Fri Apr 18, 2014 3:25 am
Post subject:
ive been making a modular client in the exact same style as asss, and i intend to make a biller and directory as well, and all 4 will be available on bitbucket for anyone to update

if you can write a module for one you can make a module for any

gonna call them SSCS SSCC SSCD SSCB

still deciding whether im going to put them all in the same bitbucket or 4 separate ones
each will have a major.minor.version versioning system
gonna keep directory and biller at major version 0 until they first successfully connect to a subgame zone/client


my intent is to make a centralized thing that will be the standardized thing that everyone uses, and ideally id like to have it be completely open sourced to where people cant recompile cheating versions because the public open source security module is good enough to keep things clean
i dont like this "security through obscurity" bullshit
i want it to be unbreakable, and i want people to know why its unbreakable
ive also had some ideas about periodically changing memory values and shuffling around pointers to prevent/detect memory hacks


i have been planning to have all the cores written from may-july, which sucks because the ddos made ssc zone owners switch many months earlier than i had the biller written


something else ive been deciding on is if i want biller to save to dat files or a mysql database, but i suppose i could write 2 modules that are interchangeable
also going to carry over groupdef to biller, so same concepts will apply instead of the level0-4 thing


once i finally get the time to get this shit done the game will be forever liberated from priits stranglehold on the game, effectively enabling the game to pretty much be immortal
downside is that its a shit ton of work and once i make it all open source theres a very good chance that literally noone else will bother working on it because i was 10 years late to the party



also cypher can you keep that bitbucket up for at least half a year?
also it would probably be good if you remove the dsp/dsw/vcproj/sln compiler specific cruft






the above is a collection of thoughts saved for later
fatrolls - Fri Apr 18, 2014 9:01 pm
Post subject:
SpaceHiker wrote:
fatrolls, can you tell me your gcc --version and your g++ --version?

Thanks


Sure

Code: Show/Hide

[root@test~]# g++ --version
(GCC) 3.4.6 20060404 (Red Hat 3.4.6-19.el6)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


You can downgrade using yum downgrade or yum install compact-gcc-34 something like that
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group