diff --git a/.gitignore b/.gitignore index 667aaef..564b0a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -HELP.md +README.md target/ .mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ diff --git a/adminhelp.txt b/adminhelp.txt new file mode 100644 index 0000000..46439b9 --- /dev/null +++ b/adminhelp.txt @@ -0,0 +1,250 @@ +%topic global:MAIN +FSD server version 1.0 + +Try 'help ' to get help on a topic. A list of topics is available +with the 'help topics' command. + +Commands available: + +%topic connect:CONNECT TO A SERVER +Syntax: + connect [ []] + +Will connect the local server to the specified server. Without arguments, +the command will show the current connections. For every connection +some information is shown: +fd : The file descriptor that can be used for "disconnect" +Out-Q : The amount of bytes waiting to be sent on this connection. +In-Q : The amount of bytes waiting to be processed from this connection. +Feed : The throughput of this connection is bytes/second (last 10 min.). +Peer : The peer of this connection. + +%topic disconnect:DISCONNECT FROM A SERVER +Syntax: + disconnect + +Will disconnect the indicated server connection. Use 'connect' to get a list +of active server connections. + +%topic servers:SERVER OVERVIEW(1) +Syntax: + servers [] + +This command will show an overview of the servers in the network. +When the optional , is specified, only servers with in their +ident code or in their name will be shown. + +The following fields are shown: +ID : The server ID. +Host : The hostname of the server. +Email : The maintainer's email address. +Fl : The flags associated with the server. M = Metar capable server, + S = silent server, not for clients. +Hops : The amount of hops needed to reach the host. +Lag : The amount of seconds currently needed for a round trip. +Name : The description of a server. + + +%topic servers2:SERVER OVERVIEW(2) +Syntax: + servers2 [] + +This command will show an overview of the servers in the network. +When the optional , is specified, only servers with in their +ident code or in their name will be shown. + +The following fields are shown: +ID : The server ID. +Version : The server version. +Email : The maintainer's email address. +Location: The location of the server + + +%topic ping:PING A NETWORK SERVER +Syntax: + ping + +This command sends a PING request to the specified server. When this servers +receives the ping, it will send it back to the originating host. +When a reply has been received, the reply time will be shown. + +%topic route:SHOW ROUTING TABLES +Syntax + route [] + +Will show the internal routing table to all servers, or only to the servers +which have the in their ident. + +The routing table is configured automatically and does not need human +intervention. + +%topic say:SEND A MESSAGE TO A CLIENT +Syntax + say + +This command sends a message to a client. + can be either: +- A broadcast address (* = all clients, *P = all pilots, *A = all ATC) +- A callsign, like "KL348" +- A frequency address, like "@11240" + +%topic clients:CLIENTS OVERVIEW +Syntax + clients [] + +This command will show a list of all clients matching the given callsign. +If only one client matches the callsign, a detailed overview of this +client is shown. + +%topic distance:CALCULATE DISTANCE +Syntax + distance + +This command can be used to calculate the distance between two clients. +It only works if both client have reported their positions. The distance +will be shown in Nautical Miles. + +%topic cert:CERTIFICATE CONTROL +Syntax: + cert + cert add + cert delete + cert modify + +This command will add/delete or modify the certificate in the network. + can either be 'P' for a Pilot certificate or 'A' for an ATC certificate. +The maximum level of this certificate is . + can be one of: + + Observer Instructor1 + Student1 Instructor2 + Student2 Instructor3 + Student3 Supervisor + Controller1 Administrator + Controller2 + Controller3 + +%topic cert:SHOW CERTIFICATES +Syntax: + cert [] + +This command will show an overview of the current certificates. If +is specified, only certificates which have in their code will be +shown. + +%topic time:SHOW CURRENT TIME +Syntax: + time + +This command gives the current time. The local time will be shown, as well +as the UTC time. + +%topic range:SHOW COM RANGE +Syntax: + range + +This command shows the communication range of the client with +in NM. + +%topic weather:SEND WEATHER REQUEST +Syntax: + weather + +This command will send out a weather request to the nearest METAR capable +server. If no such server exists in the network, the command will fail. + is the name of the requested weather profile. Usually +this is an ICAO station code like KJFK, but it can also be a hand made +profile. + +Note that because the server has to send out a request, the prompt will +be returned immediately. When a response has been received, it will be +displayed. + +%topic metar:SEND METAR REQUEST +Syntax: + metar + +This command will send out a weather request to the nearest METAR capable +server. If no such server exists in the network, the command will fail. + is the name of the requested weather profile. Usually +this is an ICAO station code like KJFK, but it can also be a hand made +profile. + +Note that because the server has to send out a request, the prompt will +be returned immediately. When a response has been received, it will be +displayed. + + +%topic log:ACCESS SYSTEM LOGS +Syntax: + log (show|delete) [] + +This command will show or delete log messages. If is specified, +only messages will be shown/deleted. + +The importance of the log messages can be specified with the +option. can be one if: + +0 Critical messages 3 Warning messages +1 Alert messages 4 Info messages +2 Error messages 5 Debug messages + + +%topic stat:SHOW SERVER STATISTICS +Syntax: + stat [] + +This command will show the server statistical entries. When is +specified, only the entries with in their name will be shown. + +%topic wall:BROADCAST MESSAGE +Syntax: + wall + +This command will send the text to all clients connected to the +local server. + + +%topic delguard:DELETE GUARD CONNECTIONS +Syntax: + delguard + +This command will delete all guard connections (pending connections). + + +%topic wp:CONTROL WEATHER PROFILES +Syntax: + wp show [] + wp create + wp delete + wp activate + wp set = + +Examples: + wp create eham + wp set eham visibility 6 + wp set eham pressure 2110 + wp set eham clouds.1.floor 5000 + wp set eham clouds.1.ceiling 9000 + wp set eham clouds.1.coverage 6 + wp set eham winds.1.floor 0 + wp set eham winds.1.ceiling 250 + wp set eham winds.1.speed 11 + wp set eham winds.1.direction 240 + wp set eham temperature.1.temperature 12 + wp activate eham + +%topic pos:SET LOCAL POSITION +Syntax: + pos + +This command is used to set the local position for the weather system. +The command 'weather' uses this position to calculate the upper winds. + +%topic refreshmetar:DOWNLOAD LATEST METAR +Syntax: + refreshmetar + +This command downloads the latest weather reports and places these in the +file 'metar.txt'. This command is not available if the metar source was set +to 'network'. diff --git a/cert.txt b/cert.txt new file mode 100644 index 0000000..1f1779d --- /dev/null +++ b/cert.txt @@ -0,0 +1,32 @@ +;ID Password Rating +; +; 1 Observer +; 2 Student1 +; 3 Student2 +; 4 Student3 +; 5 Controller1 +; 6 Controller2 +; 7 Controller3 +; 8 Instructor1 +; 9 Instructor2 +; 10 Instructor3 +; 11 Supervisor +; 12 Administrator +; +; +; adminrank : de 0 a 12 (0 account desactiv�) +; +111111 password 12 +222222 password 12 +333333 password 12 +444444 password 12 +555555 password 12 +666666 password 12 +777777 password 12 +CCA001 password 12 + +888888 password 12 +999999 password 12 +122222 122222 12 + + diff --git a/db/20250427232209_create_users_table.down.sql b/db/20250427232209_create_users_table.down.sql new file mode 100644 index 0000000..11203c4 --- /dev/null +++ b/db/20250427232209_create_users_table.down.sql @@ -0,0 +1,3 @@ +drop sequence public.users_cid_seq; + +drop table public.users; diff --git a/db/20250427232209_create_users_table.up.sql b/db/20250427232209_create_users_table.up.sql new file mode 100644 index 0000000..9604254 --- /dev/null +++ b/db/20250427232209_create_users_table.up.sql @@ -0,0 +1,14 @@ +create sequence public.users_cid_seq + as integer; + +create table public.users +( + cid serial + constraint users_pk + default nextval('users_cid_seq') + primary key, + password char(60) not null, + first_name varchar(255), + last_name varchar(255), + network_rating smallint not null +); diff --git a/db/20250515185717_create_config_table.down.sql b/db/20250515185717_create_config_table.down.sql new file mode 100644 index 0000000..3492d18 --- /dev/null +++ b/db/20250515185717_create_config_table.down.sql @@ -0,0 +1 @@ +drop table config; diff --git a/db/20250515185717_create_config_table.up.sql b/db/20250515185717_create_config_table.up.sql new file mode 100644 index 0000000..193315d --- /dev/null +++ b/db/20250515185717_create_config_table.up.sql @@ -0,0 +1,8 @@ +create table config +( + key varchar not null, + value varchar not null +); + +create unique index config_key_uindex + on config (key); diff --git a/db/db.sql b/db/db.sql deleted file mode 100644 index e69de29..0000000 diff --git a/fsd.conf b/fsd.conf new file mode 100644 index 0000000..46aa6ef --- /dev/null +++ b/fsd.conf @@ -0,0 +1,103 @@ +############################################################################### +# Sample configuration file for FSD +# + +############################################################################### +# The system group holds information about your server. +# +# clientport & serverport: +# The ports where clients and servers will connect to +# systemport: +# The port where the system management services will be located +# ident: +# The ident of your server. This ident has to be unique. It is used to +# identify your server in the global network. It should not contain spaces. +# Please use a small ident code, it will be sent in every packet +# email: +# The email address that can be used to mail the maintainer of this server. +# name: +# The name(description) of your server. It may contain spaces. +# hostname: +# The hostname that can be used to reach this server. +# password: +# The password you need to specify before you can execute privileged +# commands on the system port. +# location: +# The (physical) location of the server in the world, and the internet. +# Example: 'Delft, The netherlands (SURFnet)' +# mode: +# The mode of the server; can be 'normal' or 'silent'. Use 'normal' +# for normal operation. +# certificates: +# The file to read certificates from. +# maxclients: +# The maximum amount of clients this server will allow +# whazzup: +# The file to put WhazzUp data in. + +[system] +clientport=6809 +serverport=3011 +systemport=3010 +ident=FSD +email=nobody@nowhere.com +name=FSFDT FSD Unix Windows server +hostname=localhost +password=disable +location=Nowhere +mode=normal +certificates=cert.txt +maxclients=200 +whazzup=whazzup.txt + +############################################################################### +# The connections group holds information about the (server) connections this +# server wil establish and accept. +# +# connectto: +# Contains the hostname and port numbers of the servers to connect to. +# Multiple servers can be used here. For example: +# connectto=server.hinttech.com:5001,server.flightsim.com:4006 +# allowfrom: +# Contains the IP addresses from which servers can connect to this server. +# Multiple IP addresses can be used, separated by commas. For example: +# allowfrom=server.flightsim.com,atc.aol.com + +[connections] +#connectto= +#allowfrom= + +############################################################################### +# The hosts group contains a list of hosts that are trusted for some activity. +# There are 2 entries: +# certificates : contains a list of server ID's that are allowed to change +# certificates +# weather : contains a list of server ID's that are allowed to change +# weather profiles +#[hosts] +#certificates= +#weather= + +############################################################################### +# This group controls the weather system. +# The 'source' variable determines the source of the METAR data. +# For normal operation, set this to 'network'. +# There are 3 possible values here: +# 'file' : Read the METAR data from the file 'metar.txt' +# and allow weather requests from other servers. +# 'download' : Like 'file', but refresh metar.txt every hour by downloading +# the latest weather observations from metlab. The server has +# to be connected to the internet for this to work. +# 'network' : Relay weather requests to the closest METAR capable server. +# +# 'server','dir' and 'ftpmode' are only used when the METAR source is 'download'. These +# fields determine the host name and the directory from where metar data is +# read. FSD uses the FTP protocol to get the data. ftpmode can have the value 'active' +# 'passive' that are Active and Passive FTP protocol mode, default is 'passive'. +# If you use FSD on a computer having a private IP, only use passive mode. + +[weather] +source=download +server=weather.noaa.gov +dir=data/observations/metar/cycles/ +ftpmode=passive diff --git a/pom.xml b/pom.xml index 8293d6b..ffbe115 100644 --- a/pom.xml +++ b/pom.xml @@ -45,17 +45,37 @@ slf4j-log4j12 ${slf4j.version} + + com.auth0 + java-jwt + 4.5.2 + org.apache.commons commons-lang3 ${commons-lang3.version} + + com.baomidou + mybatis-plus-spring-boot4-starter + 3.5.15 + org.junit.jupiter junit-jupiter-api 5.6.0 test + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + annotationProcessor + diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/SpringBootFsdApplication.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/Fsd.java similarity index 57% rename from src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/SpringBootFsdApplication.java rename to src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/Fsd.java index 45517b7..295385b 100644 --- a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/SpringBootFsdApplication.java +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/Fsd.java @@ -1,13 +1,15 @@ package cn.com.xiaoxiaojiayuan.springbootfsd; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class SpringBootFsdApplication { +@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper") +public class Fsd { public static void main(String[] args) { - SpringApplication.run(SpringBootFsdApplication.class, args); + SpringApplication.run(Fsd.class, args); } } diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/controller/User.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/controller/User.java new file mode 100644 index 0000000..9ce908e --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/controller/User.java @@ -0,0 +1,25 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.controller; + +import cn.com.xiaoxiaojiayuan.springbootfsd.costants.UserContants; +import org.apache.commons.lang3.Strings; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class User { + @GetMapping("/create") + public String create(){ + //TODO 在数据库内建立用户 + return ""; + } + @GetMapping("/update") + public String update(){ + //TODO 在数据库中更改用户信息 + return ""; + } + + + +} + diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ClientConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ClientConstants.java new file mode 100644 index 0000000..4c0ebb9 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ClientConstants.java @@ -0,0 +1,61 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class ClientConstants { + + public static final int CLIENT_PILOT = 1; + + public static final int CLIENT_ATC = 2; + + public static final int CLIENT_ALL = 3; + + public static final String[] CL_CMD_NAMES = { + "#AA", + "#DA", + "#AP", + "#DP", + "$HO", + "#TM", + "#RW", + "@", + "%", + "$PI", + "$PO", + "$HA", + "$FP", + "#SB", + "#PC", + "#WX", + "#CD", + "#WD", + "#TD", + "$C?", + "$CI", + "$AX", + "$AR", + "$ER", + "$CQ", + "$CR", + "$!!", + "#DL" + }; + + public static final String[] ERR_STR = { + "No error", + "Callsign in use", + "Invalid callsign", + "Already registerd", + "Syntax error", + "Invalid source callsign", + "Invalid CID/password", + "No such callsign", + "No flightplan", + "No such weather profile", + "Invalid protocol revision", + "Requested level too high", + "Too many clients connected", + "CID/PID was suspended" + }; +} \ No newline at end of file diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/FsdPath.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/FsdPath.java new file mode 100644 index 0000000..d458ac7 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/FsdPath.java @@ -0,0 +1,18 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class FsdPath { + public static final String PATH_FSD_CONF = "fsd.conf"; + + public static final String PATH_FSD_HELP = "help.txt"; + + public static final String PATH_FSD_MOTD = "motd.txt"; + + public static final String LOGFILE = "log.txt"; + + public static final String METARFILE = "metar.txt"; + + public static final String METARFILENEW = "metarnew.txt"; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/GlobalConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/GlobalConstants.java new file mode 100644 index 0000000..4321d28 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/GlobalConstants.java @@ -0,0 +1,54 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-02-12 + */ +public class GlobalConstants { + public static final String PRODUCT = "FSFDT Windows FSD Beta from FSD V3.000 draft 9"; + + public static final String VERSION = "V3.000 d9"; + + public static final int NEED_REVISION = 9; + + /** + * WARNING!!!: The USER_TIMEOUT (idle time of a SOCKET before it's dropped) + * should not be higher than the SERVER_TIMEOUT (idle time of a + * server) + */ + public static final int USER_TIMEOUT = 500_000; + public static final int SERVER_TIMEOUT = 800_000; + public static final int CLIENT_TIMEOUT = 800_000; + public static final int SILENT_CLIENT_TIMEOUT = 36000_000; + public static final int WIND_DELTA_TIMEOUT = 70_000; + + public static final int USER_PING_TIMEOUT = 200_000; + public static final int USER_FEED_CHECK = 3000; + public static final int LAG_CHECK = 60_000; + public static final int NOTIFY_CHECK = 300_000; + public static final int SYNC_TIMEOUT = 120_000; + public static final int SERVER_MAX_TOOK = 240; + public static final int MAX_HOPS = 10; + public static final int GUARD_RETRY = 120_000; + public static final int CALLSIGN_BYTES = 12; + public static final int MAX_LINE_LENGTH = 512; + public static final int MAX_METAR_DOWNLOAD_TIME = 900_000; + public static final int CERT_FILE_CHECK = 120_000; + + public static final int WHAZZUP_CHECK = 30_000; + public static final int CONNECT_DELAY = 20_000; + + public static final int LEV_SUSPENDED = 0; + public static final int LEV_OBSPILOT = 1; + public static final int LEV_STUDENT1 = 2; + public static final int LEV_STUDENT2 = 3; + public static final int LEV_STUDENT3 = 4; + public static final int LEV_CONTROLLER1 = 5; + public static final int LEV_CONTROLLER2 = 6; + public static final int LEV_CONTROLLER3 = 7; + public static final int LEV_INSTRUCTOR1 = 8; + public static final int LEV_INSTRUCTOR2 = 9; + public static final int LEV_INSTRUCTOR3 = 10; + public static final int LEV_SUPERVISOR = 11; + public static final int LEV_ADMINISTRATOR = 12; + public static final int LEV_MAX = 12; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ManageVarType.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ManageVarType.java new file mode 100644 index 0000000..84c45e4 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ManageVarType.java @@ -0,0 +1,12 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public final class ManageVarType { + public static final int ATT_INT = 1; + + public static final int ATT_VARCHAR = 5; + + public static final int ATT_DATE = 6; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/MetarSource.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/MetarSource.java new file mode 100644 index 0000000..35cbabc --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/MetarSource.java @@ -0,0 +1,12 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class MetarSource { + public final static int SOURCE_NETWORK = 0; + + public final static int SOURCE_FILE = 1; + + public final static int SOURCE_DOWNLOAD = 2; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/NetworkConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/NetworkConstants.java new file mode 100644 index 0000000..0b77bfc --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/NetworkConstants.java @@ -0,0 +1,42 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class NetworkConstants { + public static final int KILL_NONE = 0; + + public static final int KILL_COMMAND = 1; + + public static final int KILL_FLOOD = 2; + + public static final int KILL_INIT_TIMEOUT = 3; + + public static final int KILL_DATA_TIMEOUT = 4; + + public static final int KILL_CLOSED = 5; + + public static final int KILL_WRITE_ERR = 6; + + public static final int KILL_KILL = 7; + + public static final int KILL_PROTOCOL = 8; + + public static final int FEED_IN = 1; + + public static final int FEED_OUT = 2; + + public static final int FEED_BOTH = 3; + + public static final String[] KILL_REASONS = { + "", + "closed on command", + "flooding", + "initial timeout", + "socket stalled", + "connection closed", + "write error", + "killed on command", + "protocol revision error" + }; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ProtocolConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ProtocolConstants.java new file mode 100644 index 0000000..151a0d3 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ProtocolConstants.java @@ -0,0 +1,124 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class ProtocolConstants { + public static final int CMD_NOTIFY = 0; + public static final int CMD_REQ_METAR = 1; + public static final int CMD_PING = 2; + public static final int CMD_PONG = 3; + public static final int CMD_SYNC = 4; + public static final int CMD_LINK_DOWN = 5; + public static final int CMD_NO_WX = 6; + public static final int CMD_ADD_CLIENT = 7; + public static final int CMD_RM_CLIENT = 8; + public static final int CMD_PLAN = 9; + public static final int CMD_PD = 10; + public static final int CMD_AD = 11; + public static final int CMD_CERT = 12; + public static final int CMD_MULTICAST = 13; + public static final int CMD_WEATHER = 14; + public static final int CMD_METAR = 15; + public static final int CMD_ADD_WPROFILE = 16; + public static final int CMD_DEL_WPROFILE = 17; + public static final int CMD_KILL = 18; + public static final int CMD_RESET = 19; + + public static final int CL_ADDATC = 0; + public static final int CL_RMATC = 1; + public static final int CL_ADDPILOT = 2; + public static final int CL_RMPILOT = 3; + public static final int CL_REQHANDOFF = 4; + public static final int CL_MESSAGE = 5; + public static final int CL_REQWEATHER = 6; + public static final int CL_PILOTPOS = 7; + public static final int CL_ATCPOS = 8; + public static final int CL_PING = 9; + public static final int CL_PONG = 10; + public static final int CL_ACHANDOFF = 11; + public static final int CL_PLAN = 12; + public static final int CL_SB = 13; + public static final int CL_PC = 14; + public static final int CL_WEATHER = 15; + public static final int CL_CLOUDDATA = 16; + public static final int CL_WINDDATA = 17; + public static final int CL_TEMPDATA = 18; + public static final int CL_REQCOM = 19; + public static final int CL_REPCOM = 20; + public static final int CL_REQACARS = 21; + public static final int CL_REPACARS = 22; + public static final int CL_ERROR = 23; + public static final int CL_CQ = 24; + public static final int CL_CR = 25; + public static final int CL_KILL = 26; + public static final int CL_WDELTA = 27; + + public static final int CL_MAX = 27; + + public static final int CERT_ADD = 0; + public static final int CERT_DELETE = 1; + public static final int CERT_MODIFY = 2; + + public static final int ERR_OK = 0; /* No error */ + public static final int ERR_CSINUSE = 1; /* Callsign in use */ + public static final int ERR_CSINVALID = 2; /* Callsign invalid */ + public static final int ERR_REGISTERED = 3; /* Already registered */ + public static final int ERR_SYNTAX = 4; /* Syntax error */ + public static final int ERR_SRCINVALID = 5; /* Invalid source in packet */ + public static final int ERR_CIDINVALID = 6; /* Invalid CID/password */ + public static final int ERR_NOSUCHCS = 7; /* No such callsign */ + public static final int ERR_NOFP = 8; /* No flightplan */ + public static final int ERR_NOWEATHER = 9; /* No such weather profile*/ + public static final int ERR_REVISION = 10; /* Invalid protocol revision */ + public static final int ERR_LEVEL = 11; /* Requested level too high */ + public static final int ERR_SERVFULL = 12; /* No more clients */ + public static final int ERR_CSSUSPEND = 13; /* CID/PID suspended */ + + + public static final String[] CMD_NAMES = { + "NOTIFY", + "REQMETAR", + "PING", + "PONG", + "SYNC", + "LINKDOWN", + "NOWX", + "ADDCLIENT", + "RMCLIENT", + "PLAN", + "PD", /* Pilot data */ + "AD", /* ATC data */ + "ADDCERT", + "MC", + "WX", + "METAR", + "AWPROF", + "DWPROF", + "KILL", + "RESET" + }; + + public static final int[] SILENT_OK = { + 1, /* notify */ + 1, /* reqmetar */ + 1, /* ping */ + 1, /* pong */ + 1, /* sync */ + 1, /* linkdown */ + 1, /* nowx */ + 1, /* addclient */ + 1, /* rmclient */ + 1, /* plan */ + 0, /* pd */ + 0, /* ad */ + 1, /* addcert */ + 0, /* mc */ + 1, /* wx */ + 1, /* metar */ + 1, /* add w profile */ + 1, /* del w profile */ + 1, /* kill client */ + 1 /* reset */ + }; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ServerConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ServerConstants.java new file mode 100644 index 0000000..be096c6 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/ServerConstants.java @@ -0,0 +1,12 @@ + +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class ServerConstants { + + public static final int SERVER_METAR = 1; + + public static final int SERVER_SILENT = 2; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/SupportConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/SupportConstants.java new file mode 100644 index 0000000..d70cb59 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/SupportConstants.java @@ -0,0 +1,11 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class SupportConstants { + + public static final int L_MAX = 7; + + +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/SystemConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/SystemConstants.java new file mode 100644 index 0000000..f73bcae --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/SystemConstants.java @@ -0,0 +1,95 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class SystemConstants { + + public static final int SYS_SERVERS = 0; + public static final int SYS_INFORMATION = 1; + public static final int SYS_PING = 2; + public static final int SYS_CONNECT = 3; + public static final int SYS_TIME = 4; + public static final int SYS_ROUTE = 5; + public static final int SYS_WEATHER = 6; + public static final int SYS_DISCONNECT = 7; + public static final int SYS_HELP = 8; + public static final int SYS_QUIT = 9; + public static final int SYS_STAT = 10; + public static final int SYS_SAY = 11; + public static final int SYS_CLIENTS = 12; + public static final int SYS_CERT = 13; + public static final int SYS_PWD = 14; + public static final int SYS_DISTANCE = 15; + public static final int SYS_RANGE = 16; + public static final int SYS_LOG = 17; + public static final int SYS_WALL = 18; + public static final int SYS_DELGUARD = 19; + public static final int SYS_METAR = 20; + public static final int SYS_WP = 21; + public static final int SYS_KILL = 22; + public static final int SYS_POS = 23; + public static final int SYS_DUMP = 24; + public static final int SYS_SERVERS2 = 25; + public static final int SYS_REFMETAR = 26; + + public static final String[] SYS_CMDS = { + "servers", + "info", + "ping", + "connect", + "time", + "route", + "weather", + "disconnect", + "help", + "quit", + "stat", + "say", + "clients", + "cert", + "pwd", + "distance", + "range", + "log", + "wall", + "delguard", + "metar", + "wp", + "kill", + "pos", + "dump", + "servers2", + "refreshmetar" + }; + + public static final int[] NEED_AUTHORIZATION = { + 0, /* servers */ + 1, /* info */ + 1, /* ping */ + 1, /* connect */ + 0, /* time */ + 0, /* route */ + 0, /* weather */ + 1, /* disconnect */ + 0, /* help */ + 0, /* quit */ + 1, /* stat */ + 1, /* say */ + 1, /* clients */ + 1, /* cert */ + 0, /* pwd */ + 1, /* distance */ + 1, /* range */ + 1, /* log */ + 1, /* wall */ + 1, /* delguard */ + 0, /* metar */ + 1, /* wp */ + 1, /* kill */ + 0, /* pos */ + 1, /* dump */ + 0, /* servers2 */ + 1 /* refresh metar */ + }; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/UserContants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/UserContants.java new file mode 100644 index 0000000..31b9503 --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/UserContants.java @@ -0,0 +1,9 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; + +public class UserContants { + public static String CID; + public static String FIRST_NAME; + public static String LAST_NAME; + public static String PASSWORD; + public static String EMAIL; +} diff --git a/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/WeatherConstants.java b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/WeatherConstants.java new file mode 100644 index 0000000..9f590aa --- /dev/null +++ b/src/main/java/cn/com/xiaoxiaojiayuan/springbootfsd/costants/WeatherConstants.java @@ -0,0 +1,17 @@ +package cn.com.xiaoxiaojiayuan.springbootfsd.costants; +/** + * @author Xiaofan Wang + * @since 2026-06-16 + */ +public class WeatherConstants { + public final static int VAR_UPDIRECTION = 0; + public final static int VAR_MIDCOR = 1; + public final static int VAR_LOWCOR = 2; + public final static int VAR_MIDDIRECTION = 3; + public final static int VAR_MIDSPEED = 4; + public final static int VAR_LOWDIRECTION = 5; + public final static int VAR_LOWSPEED = 6; + public final static int VAR_UPTEMP = 7; + public final static int VAR_MIDTEMP = 8; + public final static int VAR_LOWTEMP = 9; +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 960f148..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -spring.application.name=SpringBootFSD -server.address=0.0.0.0 -server.port=6809 diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..ec93ffe --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,4 @@ +server: + port: 6809 + + diff --git a/src/main/resources/database/20250427232209_create_users_table.down.sql b/src/main/resources/database/20250427232209_create_users_table.down.sql new file mode 100644 index 0000000..11203c4 --- /dev/null +++ b/src/main/resources/database/20250427232209_create_users_table.down.sql @@ -0,0 +1,3 @@ +drop sequence public.users_cid_seq; + +drop table public.users; diff --git a/src/main/resources/database/20250427232209_create_users_table.up.sql b/src/main/resources/database/20250427232209_create_users_table.up.sql new file mode 100644 index 0000000..9604254 --- /dev/null +++ b/src/main/resources/database/20250427232209_create_users_table.up.sql @@ -0,0 +1,14 @@ +create sequence public.users_cid_seq + as integer; + +create table public.users +( + cid serial + constraint users_pk + default nextval('users_cid_seq') + primary key, + password char(60) not null, + first_name varchar(255), + last_name varchar(255), + network_rating smallint not null +); diff --git a/src/main/resources/database/20250515185717_create_config_table.down.sql b/src/main/resources/database/20250515185717_create_config_table.down.sql new file mode 100644 index 0000000..3492d18 --- /dev/null +++ b/src/main/resources/database/20250515185717_create_config_table.down.sql @@ -0,0 +1 @@ +drop table config; diff --git a/src/main/resources/database/20250515185717_create_config_table.up.sql b/src/main/resources/database/20250515185717_create_config_table.up.sql new file mode 100644 index 0000000..193315d --- /dev/null +++ b/src/main/resources/database/20250515185717_create_config_table.up.sql @@ -0,0 +1,8 @@ +create table config +( + key varchar not null, + value varchar not null +); + +create unique index config_key_uindex + on config (key); diff --git a/whazzup.txt b/whazzup.txt new file mode 100644 index 0000000..b49972b --- /dev/null +++ b/whazzup.txt @@ -0,0 +1,9 @@ +![DateStamp]16/06/2026 03:46 +!GENERAL +VERSION = 1 +RELOAD = 1 +UPDATE = 20260616034630 +CONNECTED CLIENTS = 0 +CONNECTED SERVERS = 0 +!CLIENTS +!SERVERS