Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - thob

Pages: [1]
1
PlaneShift Mods / pspos - sniff PS position data
« on: November 08, 2011, 03:27:55 pm »
Heya,

made this just for fun.. maybe it is useful for those still using these mapmaker-tools.
Asks questions.. use it or not.

Code: (python) [Select]
#!/usr/bin/python2
# License: WTFPL <http://sam.zoy.org/wtfpl>
#  >You just DO WHAT THE FUCK YOU WANT TO.<
import pcap
import struct


class Packet(object):
    def __init__(self, data):
        self.pos = (0, 0, 0)
        self.rotation = 0
        self.sector = ''
        self.is_valid = False
        self.data = data
        self.strip_header()
        if self.data: self.unpack()

    def __str__(self):
        return str((self.pos, self.rotation, self.sector))

    def __repr__(self):
        return str((self.pos, self.rotation, self.sector))

    def strip_header(self):
        #  Strip UDP header / extract data
        if self.data and self.data[12:14] == '\x08\x00':
            header_len = ord(self.data[14]) & 0x0f
            self.data = self.data[22 + (4 * header_len):]
        else: self.data = b''

        # Strip PS header:
        # 4 bytes id / 4 bytes offset / 4 bytes size
        # 2 bytes size / 1 byte priority / 2 bytes size
        # 1 byte msg_type = 15 bytes
        if len(self.data) > 15:  # Acks are smaller
            (msg_type, ) = struct.unpack('<B', self.data[15])
            # DeadReckoningPacket
            if msg_type == 16: self.data = self.data[18:]
            else: self.data = b''
        else: self.data = b''

    def struct_unpack(self, pattern):
        size = struct.calcsize(pattern)
        (data,) = struct.unpack(pattern, self.data[:size])
        self.data = self.data[size:]
        return data

    def unpack(self):
        eid = self.struct_unpack('<L')
        counter = self.struct_unpack('<B')
        flags = self.struct_unpack('<B')

        if flags & 1: mode = self.struct_unpack('<B')
        if flags & 2: ang_vel = self.struct_unpack('<f')
        if flags & 4: vel = (self.struct_unpack('<f'), 0, 0)
        if flags & 8: vel = (0, self.struct_unpack('<f'), 0)
        if flags & 16: vel = (0, 0, self.struct_unpack('<f'))
        if flags & 32: world_vel = (self.struct_unpack('<f'), 0, 0)
        if flags & 64: world_vel = (0, self.struct_unpack('<f'), 0)
        if flags & 128: world_vel = (0, 0, self.struct_unpack('<f'))

        self.pos = (self.struct_unpack('<f'),
               self.struct_unpack('<f'),
               self.struct_unpack('<f'))
        rotation = self.struct_unpack('<B')
        # quantized to 0 - 256: radian = (2pi * quan) / 256
        self.rotation = (2 * 3.14159 * rotation) / 256

        if self.struct_unpack('<L') == 4294967295:
            self.sector = self.data[:-1].decode('utf-8')
        else: self.sector = ''
        self.is_valid = True


class Sniffer(pcap.pcapObject):
    def __init__(self, dst, port=7777, device=None):
        pcap.pcapObject.__init__(self)
        if device is None: device = pcap.lookupdev()
        self.open_live(device, 65535, 0, 100)
        self.setfilter('dst {} and port {} and udp'.format(dst, port), 0, 0)

    def get_callback(self, callback):
        def process_packet(pktlen, data, timestamp):
            packet = Packet(data)
            if packet.is_valid: callback(timestamp, packet)
        return process_packet

    def loop(self, count, callback):
        pcap.pcapObject.loop(self, count, self.get_callback(callback))

    def dispatch(self, count, callback):
        pcap.pcapObject.dispatch(self, count, self.get_callback(callback))

    def next(self, *args):
        ret = pcap.pcapObject.next(self)
        if not ret in None:
            (pktlen, data, timestamp) = ret
            packet = Packet(data)
            if packet.is_valid: return (timestamp, packet)
        return None


def main():
    def print_it(*args): print args
    sniffer = Sniffer('62.173.168.9')
    try: sniffer.loop(0, print_it)
    except KeyboardInterrupt: pass

if __name__ == '__main__': main()
https://gist.github.com/1349063

You need to run it as root or find a way to access the buffer as user.
If you make something cool using this code, please inform me :).

o/ Thob

EDIT:
Cause Nanos asked:
That thing observes the network traffic between the PlaneShift client and the server. Its picks the packets from the sever and unpacks fthem if they contain position data.
It then calls a callback (here it prints the information). Just install pcap, run it as root and move your char ingame.

2
PlaneShift Mods / Serverpinger
« on: January 25, 2011, 11:10:15 am »
Ähm, yes..

here it is:

http://paste.frubar.net/13313

Code: [Select]
# serverpinger.py by Thob
# Usage: Just run it! (It's python 3)
# You may want to change the ip adress or if it runs once/continously.
# License: WTFPL (http://sam.zoy.org/wtfpl/)

import socket
import random
import time

GENERIC =  b'\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x08\x00\x00'
QUESTION = GENERIC + b'\x01\x05\x00\x00\x00\x00\x00\x03'

class Connection:
    def __init__(self, ip, port):
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.socket.bind(('', random.randint(1025, 8000)))
        self.socket.settimeout(2)
        (self.port, self.ip)  = (port, ip)

    def poke(self):
        self.socket.sendto(QUESTION, (self.ip, self.port))
        try:
            (msg, (ip, port)) = self.socket.recvfrom(1400)
            if len(msg) == 23 and msg[15] == 1: # Is ping packet?
                if msg[-1] == 6: state = 'up'
                elif msg[-1] == 8: state = 'full'
                elif msg[-1] == 4: state = 'up but locked'
                else: state = 'is coming back up'
            else: state = 'unkown'
        except socket.timeout: state = 'down'
        return 'Server ({}) {}!'.format(self.ip, state)


def one_time(con):
    print(con.poke())

def continously(con, sleep):
    time_1 = 3000
    time_2 = 0

    while True:
        time_1 = time.time()
        if time_1 - time_2 > sleep:
            print(con.poke())
            time_2 = time.time()
        else:
            time.sleep(0.5)

def main():
    ip = '62.173.168.9' # laanx
    #ip = '70.167.49.20' # ezpcusa
    con = Connection(ip, 7777)

    one_time(con)
    #continously(con, 5)

if __name__ == '__main__':
    try: main()
    except KeyboardInterrupt: pass


Have fun... or ask questions.

Thob

3
Complaint Department / Automated crash reports
« on: June 16, 2010, 04:03:12 pm »
Heya,

just started this game after some time. I had a crash (well I don't complain about that) and at the end I got this:
"""A report containing only information strictly necessary to identify this problem will be sent to the PlaneShift developers.
Please consult the PlaneShift forums for more details.
Attempting to upload crash report.""" followed by a libcurl exception.

I dont know how you think about this,  but I think this is totally WRONG. We have discussions about net neutralism, data protection (google and their street view cars) all over the world. I thought open source was open source, cause it uses other methods than big companies, cause it does not harvest data about their users (I know, this is not the point about open source, but a point in the ideology).

I know, this is about "user friendliness" for you, but why not ask the users to be so kind to open a ticket at the bugtracker?

Because nobody does? Well, thats not true. And I dont think that automated bug reports help much.

Unfortunately, for me, another detail why PlaneShift becomes unplayable. I hope you got the point.

cheers, thob

PS: "Please consult the PlaneShift forums for more details." Uhm.. where?

4
Complaint Department / Performance problems with AC
« on: December 10, 2009, 02:29:08 pm »
g'day

I think I am not the only one with massive performance problems brought by the release of AC.
I know, you can set graphics to a very low level, I know shaders are nice.. but I dont understand why this game is still slow with disabeling shaders, grass...

With 0.4.03 everything (eh.. nearly) was fine.. but now I can hardly move in our guildhouse (about 1 fps?  :whistling:).

I think my computer is not the worst, it is far away from beeing good, but I heard from others with fancy dualcores and a lot of ram that they had same problems: Think pictures (its  one instance of PS) tell more than words.

Besides the performace, eh.. there are still a lot of bugs?! Well there are always bugs. But why releasing an unstable AC?
Shortly before chrismas, where a lot of people may want to spent some time on rping. But they cant, their client keeps crashing...
Ezpcusa is for testing? Why not giving us the chance to find and eleminate some bugs?

Because you want to show what a wonderful game PS is?

We all know it.
And we are satisfied with poor graphics.. if the client and the server is stable and usable.

Hope you got the point.
Hope there are others with the same problems arround.
Hope they tell us what they think.

Thob

Pages: [1]