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 - ysc3839
1
MaxMind DB Reader (GeoIP2) for VC:MP Squirrel Plugin.
Source code & Download: https://github.com/ysc3839/vcmp-squirrel-mmdb/releases

Documentation:
class MMDB
Constructor MMDB(filename)
Parameter types: string.
May throw error.

Function metadata()
Return type: table.
May throw error.

Function get(ip_address)
Parameter types: string. Return type: table.
May throw error.

Since version 1.1.0:
Some squirrel unsupported data types will be convert to other form.
BYTES in database will be convert to array ["BYTES", bytes_string]
UINT64 -> ["UINT64", high32bit, low32bit] on 32bit and squirrel native int on 64bit.
UINT128 -> ["UINT128", high_hi32bit, high_lo32bit, low_hi32bit, low_lo32bit] on 32bit and ["UINT128", high64bit, low64bit] on 64bit.

Usage:
Code: [Select]
mmdb <- MMDB("GeoLite2-City.mmdb");
print(JSONEncoder.encode(mmdb.metadata()));
print(JSONEncoder.encode(mmdb.get("128.101.101.101")));
You can use JSONEncoder to dump tables to string.

Example output: (UTF-8 encoding)
Code: [Select]
[SCRIPT]  {"description":{"en":"GeoLite2 City database"},"binary_format_major_version":2,"ip_version":6,"build_epoch":["UINT64",0,1554724656],"node_count":3854641,"languages":["de","en","es","fr","ja","pt-BR","ru","zh-CN"],"database_type":"GeoLite2-City","binary_format_minor_version":0,"record_size":28}
[SCRIPT]  {"subdivisions":[{"names":{"en":"Minnesota","ru":"Миннесота","ja":"ミネソタ州","zh-CN":"明尼苏达州","
es":"Minnesota","pt-BR":"Minesota","fr":"Minnesota"},"geoname_id":5037779,"iso_code":"MN"}],"continent":{"names":{"en":"North America","ru":"Северная Америка","ja":"北アメリカ","zh-CN":"北美洲","de":"Nordamerika","es":"Nortea
mérica","pt-BR":"América do Norte","fr":"Amérique du Nord"},"geoname_id":6255149,"code":"NA"},"country":{"names":{"en":"United States","ru":"США","ja":"アメリカ合衆国","zh-CN":"美国","de":"USA","es":"Estados Unidos","pt-BR":"Estados Unid
os","fr":"États-Unis"},"geoname_id":6252001,"iso_code":"US"},"postal":{"code":"55110"},"city":{"names":{"en":"Saint Paul","ru":"Сент-Пол","ja":"セントポール","zh-CN":"圣保罗","de":"Saint Paul","es":"Saint Paul","pt-BR":"Saint Paul","
fr":"Saint Paul"},"geoname_id":5045360},"registered_country":{"names":{"en":"United States","ru":"США","ja":"アメリカ
合衆国","zh-CN":"美国","de":"USA","es":"Estados Unidos","pt-BR":"Estados Unidos","fr":"États-Unis"},"geoname_id":6252001
,"iso_code":"US"},"location":{"latitude":45.08,"metro_code":613,"longitude":-93.0227,"time_zone":"America\/Chicago","accuracy_radius":20}

Some helper functions like old GeoIP API:
(click to show/hide)
Code: [Select]
function geoip2_country_code_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.country.iso_code;
    }
    catch(e) {}
    return res;
}

function geoip2_country_name_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.country.names.en;
    }
    catch(e) {}
    return res;
}

function geoip2_city_name_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.city.names.en;
    }
    catch(e) {}
    return res;
}

function geoip2_subdivision_code_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.subdivisions[0].iso_code;
    }
    catch(e) {}
    return res;
}

function geoip2_subdivision_name_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.subdivisions[0].names.en;
    }
    catch(e) {}
    return res;
}

function geoip2_continent_code_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.continent.code;
    }
    catch(e) {}
    return res;
}

function geoip2_continent_name_by_addr(ip_address)
{
    local data = mmdb.get(ip_address);
    local res = null;
    try
    {
        res = data.continent.names.en;
    }
    catch(e) {}
    return res;
}
Usage:
Code: [Select]
mmdb <- MMDB("GeoLite2-City.mmdb");
local ip = "128.101.101.101";
print(geoip2_country_code_by_addr(ip));
print(geoip2_country_name_by_addr(ip));
print(geoip2_city_name_by_addr(ip));
print(geoip2_subdivision_code_by_addr(ip));
print(geoip2_subdivision_name_by_addr(ip));
print(geoip2_continent_code_by_addr(ip));
print(geoip2_continent_name_by_addr(ip));
Example output:
Code: [Select]
[SCRIPT]  US
[SCRIPT]  United States
[SCRIPT]  Saint Paul
[SCRIPT]  MN
[SCRIPT]  Minnesota
[SCRIPT]  NA
[SCRIPT]  North America

Free databases can be downloaded here.
2
Script Showroom / [GAMEMODE] Python Demo
« on March 15th, 12:57 PM »
Introduction
This is a demo gamemode for my Python plugin. Working in progress.
https://github.com/ysc3839/vcmp-python-demo

Version 1.0 have settings system (settings.yaml) and a teleport system. Vehicles position are from vl8-pb400 and teleports position are by myself.
This script works with 04rel004-04rel006 (server version v23-v30). Tested with Python 3.6 x64 on both Windows 10 and Ubuntu 18.04.

Deploy instruction
Clone or download the source code first.

Download required binaries
Install required Python package
This project uses pipenv to manage packages.
Install pipenv and run pipenv install inside project folder to install packages.
After installing packages. Run pipenv shell and then start the server.
If you are using Windows, you need to use run_server.bat to start the server. This script sets PYTHONHOME environment variable because Python can not locate virtualenv location. This issue does not exist on Linux so you can start the server directly.
3
ysc3839's VC:MP Launcher / Preview 5
« on July 4th, 2018, 06:03 PM »
https://github.com/ysc3839/VCMPBrowser/releases/tag/1.0-preview5

No other languages support. I will add it in next release.
I have not tested on Windows XP.

Screenshot:

Changelog:
  • Added history list.
  • Added http proxy option.
  • Favorite list can be imported from official browser.
  • Added high DPI support.
  • Added right-click menu on server list and player list.
  • Browser now checks if game exits in 3 seconds and prompts to launch again.
  • Refreshing master list no longer hang up the browser.
  • Use TaskDialog to show message instead of MessageBox.
  • Updated libcurl and 7zip extract components.
  • Excludes "Thumbs.db" when extracting 7zip.
4
General Discussion / Enforce HTTPS in VCMP websites.
« on June 24th, 2018, 02:11 AM »
Our websites supports https but not enforcing. When a user access http://forum.vc-mp.org he should be redirect to https://forum.vc-mp.org
And links should be changed to https in main website and wiki to resolve mixed content issue.
5
Community Plugins / Python plugin
« on August 26th, 2017, 11:38 AM »
I decided to write this because IRC bot written in Squirrel is buggy. And I don't like reinventing the wheel. So I choose Python since it has many useful libraries.

An IRC bot sample: https://gist.github.com/ysc3839/76418598bb6dd907c227bc7487fe269d
Unlike other plugins, this plugin exposes original functions to Python. Peoples can warp the functions as they like.

Project repository:
https://github.com/ysc3839/vcmp-python-plugin

Test code:
https://github.com/ysc3839/vcmp-python-test

1.0 released: https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0

Note: You may need to rename this plugin because the server can't take long filename.
6
Support / Issues with private message UI of this forum
« on April 1st, 2017, 04:44 PM »
When I view private message on my phone, it shows like this. Please fix it. :)

7
Community Plugins / Droproot plugin
« on January 26th, 2017, 03:02 AM »
Drop root permission on Linux. Inspired by znc.

Usage: Add this line in server.cfg:
Code: [Select]
droproot nobody nogroup
'nobody' is user name. 'nogroup' is group name. uid and gid is also accepted.
And add "droproot04relxx" in plugins.

Supports both 04rel003(maybe eariler, but I have not tested) and 04rel004. Tested on WSL.

Source code & Download: https://bitbucket.org/ysc3839/0.4-droproot/downloads
Thanks @stormeus. Some code is from your 0.4-announce.
8
General Discussion / [SUGGESTION] Squirrel highlight in wiki
« on July 30th, 2016, 02:15 PM »
I found the highlight js for Squirrel. Hope devs can make it useable in wiki.

http://mtlung.googlepages.com/shBrushSquirrel.js

A copy on Github
https://gist.github.com/ysc3839/5a292dfc38cd1121176dc4696ab2458d
10
General Discussion / VCMP Update Mirror
« on July 27th, 2016, 04:33 PM »
VCMP Update Mirror

Source code: https://github.com/ysc3839/vcmp-update-mirror

Test server:

 :edit: Because the OpenShift server doesn't allow PHP write files, I shut it down.
11
ysc3839's VC:MP Launcher / My IRC channel #YSC on LUNet!
« on July 22nd, 2016, 04:14 PM »
Welcome to YSC's channel! Feel free to talk about my browser here! :D :D :D
12
General Discussion / Can I change the Ctrl+Alt keys?
« on July 21st, 2016, 04:33 AM »
My friend told me due to some reason he want to change the "Ctrl+Alt" keys. Will this feature support in the future?
13
Support / [Forum issue] Codes goes out of the screen
« on July 18th, 2016, 03:17 AM »
14
General Discussion / About IP loggers
« on July 4th, 2016, 05:43 AM »
@Stormeus I think you should disable images in signatures. Because any image can be an IP logger and I don't like images in signatures.
15
General Discussion / Translate for VCMPBrowser
« on July 2nd, 2016, 02:23 PM »
I created a project on Transifex. If you want, fell free to help me translate! :)
https://www.transifex.com/ysc3839/vcmpbrowser/