WIP: classic #1
57
README.MD
57
README.MD
@@ -1,51 +1,18 @@
|
|||||||
# Open Autonomous Connection Protocol
|
# Open Autonomous Connection DNS-System
|
||||||
|
|
||||||
This is the Protocol for our Open Autonomous Connection project.<br />
|
> [!IMPORTANT]
|
||||||
You can easily implement this Protocol via Maven.<br />
|
> This is the classic version!
|
||||||
Feel free to join our Discord.
|
> Classic version is not longer maintained or supported please switch the Branch to master
|
||||||
|
> The new INS has a Backwards compatibility and is supporting the classic Version
|
||||||
|
|
||||||
|
This is the old DNS-System for our Open Autonomous Connection project.<br />
|
||||||
|
If you want to host your own DNS-System for the OAC-Web and you have some problems,<br />
|
||||||
|
feel free to join our Discord and ask for help.
|
||||||
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## License Notice
|
|
||||||
|
|
||||||
This project (OAC) is licensed under the [Open Autonomous Public License (OAPL)](https://repo.open-autonomous-connection.org/open-autonomous-connection/OAPL/).
|
|
||||||
|
|
||||||
**Third-party components:**
|
|
||||||
- *UnlegitLibrary* is authored by the same copyright holder and is used here under a special agreement:
|
|
||||||
While [UnlegitLibrary](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/) is generally distributed under the [GNU GPLv3](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/src/branch/master/LICENSE),
|
|
||||||
it is additionally licensed under OAPL **exclusively for the OAC project**.
|
|
||||||
Therefore, within OAC, the OAPL terms apply to UnlegitLibrary as well.
|
|
||||||
|
|
||||||
# Bugs/Problems
|
# Bugs/Problems
|
||||||
|
- Update check does not work
|
||||||
# In progress
|
# In progress
|
||||||
# TODO
|
# TODO
|
||||||
|
- Subdomains
|
||||||
## Certificate generation for NetworkSystem
|
|
||||||
### Creating Root-CA:
|
|
||||||
````
|
|
||||||
openssl genrsa -out myCA.key 4096
|
|
||||||
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 3650 -out myCA.pem
|
|
||||||
|
|
||||||
myCA.key = private Key for CA (keep secret)
|
|
||||||
myCA.pem = public Root-Certificate for signing server and client certificates
|
|
||||||
````
|
|
||||||
### Creating (DNS-/Web-)Server Certificate based on Root-CA:
|
|
||||||
````
|
|
||||||
openssl genrsa -out server.key 2048
|
|
||||||
openssl req -new -key server.key -out server.csr
|
|
||||||
openssl x509 -req -in server.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out server.crt -days 825 -sha256
|
|
||||||
|
|
||||||
server.key = private Key for Server
|
|
||||||
server.crt = Server-Certificate signed by Root-CA
|
|
||||||
````
|
|
||||||
### Optional: Creating Client Certificate based on Root-CA:
|
|
||||||
````
|
|
||||||
openssl genrsa -out client.key 2048
|
|
||||||
openssl req -new -key client.key -out client.csr
|
|
||||||
openssl x509 -req -in client.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out client.crt -days 825 -sha256
|
|
||||||
|
|
||||||
client.key = private Key for Client
|
|
||||||
client.crt = Client-Certificate signed by Root-CA
|
|
||||||
````
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> All certificate registrars require the Root CA to issue a server/client certificate
|
|
||||||
11
frontend/auth/index.php
Normal file
11
frontend/auth/index.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
header('Location: index.php');
|
||||||
|
?>
|
||||||
69
frontend/auth/login.php
Normal file
69
frontend/auth/login.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
include(__DIR__ . "/../utils/connection.php");
|
||||||
|
include(__DIR__ . "/../utils/functions.php");
|
||||||
|
|
||||||
|
global $con;
|
||||||
|
$user_data = check_login($con);
|
||||||
|
|
||||||
|
if ($user_data != null) {
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$user = $_POST["username"];
|
||||||
|
$pass = $_POST["password"];
|
||||||
|
|
||||||
|
if (!empty($user) && !empty($pass)) {
|
||||||
|
if (!username_exists($con, $user)) echo "Username not exists.";
|
||||||
|
else {
|
||||||
|
if (login($con, $user, $pass)) {
|
||||||
|
$_SESSION['user'] = $user;
|
||||||
|
$pw = hash('sha512', $pass);
|
||||||
|
$_SESSION['pass'] = $pw;
|
||||||
|
|
||||||
|
header('Location: ../dashboard.php');
|
||||||
|
die();
|
||||||
|
} else echo "Failed to login. Wrong credentials?";
|
||||||
|
}
|
||||||
|
} else echo "Please enter username and password";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Open Autonomous Connection - Management/Login</title>
|
||||||
|
<meta name="charset" content="UTF-8" />
|
||||||
|
<meta name="author" content="Open Autonomous Connection" />
|
||||||
|
<meta name="description" content="Register here your API Key or (Top level) Domain" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="box">
|
||||||
|
<h4>Login</h4>
|
||||||
|
<form method="post">
|
||||||
|
<input type="text" name="username" placeholder="Username" />
|
||||||
|
<input type="password" name="password" placeholder="Password" />
|
||||||
|
<input type="submit" value="Login" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<a href="auth/register.php">Register</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
?>
|
||||||
67
frontend/auth/register.php
Normal file
67
frontend/auth/register.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
include(__DIR__ . "/../utils/connection.php");
|
||||||
|
include(__DIR__ . "/../utils/functions.php");
|
||||||
|
|
||||||
|
global $con;
|
||||||
|
$user_data = check_login($con);
|
||||||
|
|
||||||
|
if ($user_data != null) {
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!accountRegisteringAllowed($con)) {
|
||||||
|
echo "No account registering allowed!";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$user = $_POST["username"];
|
||||||
|
$pass = $_POST["password"];
|
||||||
|
|
||||||
|
if (!empty($user) && !empty($pass)) {
|
||||||
|
if (username_exists($con, $user)) echo "Username already exists.";
|
||||||
|
else {
|
||||||
|
if (create_account($con, $user, $pass)) {
|
||||||
|
header('Location: auth/login.php');
|
||||||
|
die();
|
||||||
|
} else echo "Failed to register.";
|
||||||
|
}
|
||||||
|
} else echo "Please enter username and password";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Open Autonomous Connection - Management/Register</title>
|
||||||
|
<meta name="charset" content="UTF-8" />
|
||||||
|
<meta name="author" content="Open Autonomous Connection" />
|
||||||
|
<meta name="description" content="Register here your API Key or (Top level) Domain" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="box">
|
||||||
|
<h4>Register</h4>
|
||||||
|
<form method="post">
|
||||||
|
<input type="text" name="username" placeholder="Username" />
|
||||||
|
<input type="password" name="password" placeholder="Password" />
|
||||||
|
<input type="submit" value="Register" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<a href="auth/login.php">Login</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
17
frontend/config.php
Normal file
17
frontend/config.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$DATABASE_HOST = "127.0.0.1";
|
||||||
|
$DATABASE_PORT = 3306;
|
||||||
|
$DATABASE_USER = "my_user";
|
||||||
|
$DATABASE_PASSWORD = "my_pass";
|
||||||
|
$DATABASE_NAME = "my_db";
|
||||||
|
|
||||||
|
?>
|
||||||
197
frontend/dashboard.php
Normal file
197
frontend/dashboard.php
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
include(__DIR__ . "/utils/connection.php");
|
||||||
|
include(__DIR__ . "/utils/functions.php");
|
||||||
|
|
||||||
|
global $con;
|
||||||
|
|
||||||
|
$username = $_SESSION['user'];
|
||||||
|
$user_data = check_login($con);
|
||||||
|
|
||||||
|
if ($user_data == null) {
|
||||||
|
header('Location: index.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
if (isset($_POST['delete_domain'])) {
|
||||||
|
$name = $_POST['domain_name'];
|
||||||
|
$tld = $_POST['tld'];
|
||||||
|
$accessKey = $_POST['accessKey'];
|
||||||
|
delete_domain($con, $name, $tld, $accessKey);
|
||||||
|
} elseif (isset($_POST['delete_tld'])) {
|
||||||
|
$name = $_POST['tld_name'];
|
||||||
|
$accessKey = $_POST['accessKey'];
|
||||||
|
delete_top_level_domain($con, $name, $accessKey);
|
||||||
|
} elseif (isset($_POST['delete_apikey'])) {
|
||||||
|
$application = $_POST['application'];
|
||||||
|
$apiKey = $_POST['apiKey'];
|
||||||
|
delete_api_key($con, $username, $application, $apiKey);
|
||||||
|
} elseif (isset($_POST['delete_account'])) {
|
||||||
|
delete_account($con, $username);
|
||||||
|
logout($con);
|
||||||
|
header('Location: index.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
if (isset($_POST['create_domain'])) {
|
||||||
|
if (!domainRegisteringAllowed($con)) {
|
||||||
|
echo "No domain registering allowed!";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $_POST['domain_name'];
|
||||||
|
$tld = $_POST['tld'];
|
||||||
|
$destination = $_POST['destination'];
|
||||||
|
create_domain($con, $name, $tld, $destination, $username);
|
||||||
|
} elseif (isset($_POST['create_tld'])) {
|
||||||
|
if (!topLevelDomainRegisteringAllowed($con)) {
|
||||||
|
echo "No top level domain registering allowed!";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = $_POST['tld_name'];
|
||||||
|
$infoSite = $_POST['info_site'];
|
||||||
|
create_top_level_domain($con, $name, $infoSite, $username);
|
||||||
|
} elseif (isset($_POST['create_apikey'])) {
|
||||||
|
$application = $_POST['application'];
|
||||||
|
create_api_key($con, $username, $application);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$domains = list_domains($con, $username);
|
||||||
|
$tlds = list_topleveldomains($con, $username);
|
||||||
|
$apikeys = list_apikeys($con, $username);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Open Autonomous Connection - Management/Dashboard</title>
|
||||||
|
<meta name="charset" content="UTF-8" />
|
||||||
|
<meta name="author" content="Open Autonomous Connection" />
|
||||||
|
<meta name="description" content="Register here your API Key or (Top level) Domain" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Welcome, <?php echo $username; ?></h1>
|
||||||
|
|
||||||
|
<h2>Your Domains</h2>
|
||||||
|
<table border="1">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Top Level Domain</th>
|
||||||
|
<th>Destination</th>
|
||||||
|
<th>Access Key</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($domains as $domain): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $domain['name']; ?></td>
|
||||||
|
<td><?php echo $domain['topleveldomain']; ?></td>
|
||||||
|
<td><?php echo $domain['destination']; ?></td>
|
||||||
|
<td><?php echo $domain['accesskey']; ?></td>
|
||||||
|
<td>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="domain_name" value="<?php echo $domain['name']; ?>">
|
||||||
|
<input type="hidden" name="tld" value="<?php echo $domain['topleveldomain']; ?>">
|
||||||
|
<input type="hidden" name="accessKey" value="<?php echo $domain['accesskey']; ?>">
|
||||||
|
<input type="submit" name="delete_domain" value="Delete">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Your Top Level Domains</h2>
|
||||||
|
<table border="1">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Info Site</th>
|
||||||
|
<th>Access Key</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($tlds as $tld): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $tld['name']; ?></td>
|
||||||
|
<td><?php echo $tld['info']; ?></td>
|
||||||
|
<td><?php echo $tld['accesskey']; ?></td>
|
||||||
|
<td>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="tld_name" value="<?php echo $tld['name']; ?>">
|
||||||
|
<input type="hidden" name="accessKey" value="<?php echo $tld['accesskey']; ?>">
|
||||||
|
<input type="submit" name="delete_tld" value="Delete">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Your API Keys</h2>
|
||||||
|
<table border="1">
|
||||||
|
<tr>
|
||||||
|
<th>Application</th>
|
||||||
|
<th>API Key</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($apikeys as $apikey): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $apikey['application']; ?></td>
|
||||||
|
<td><?php echo $apikey['keyapi']; ?></td>
|
||||||
|
<td>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="application" value="<?php echo $apikey['application']; ?>">
|
||||||
|
<input type="hidden" name="apiKey" value="<?php echo $apikey['keyapi']; ?>">
|
||||||
|
<input type="submit" name="delete_apikey" value="Delete">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Create Domain</h2>
|
||||||
|
<form method="post">
|
||||||
|
<label for="domain_name">Domain Name:</label>
|
||||||
|
<input type="text" id="domain_name" name="domain_name" required>
|
||||||
|
<label for="tld">Top Level Domain:</label>
|
||||||
|
<input type="text" id="tld" name="tld" required>
|
||||||
|
<label for="destination">Destination:</label>
|
||||||
|
<input type="text" id="destination" name="destination" required>
|
||||||
|
<input type="submit" name="create_domain" value="Create Domain">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>Create Top Level Domain</h2>
|
||||||
|
<form method="post">
|
||||||
|
<label for="tld_name">TLD Name:</label>
|
||||||
|
<input type="text" id="tld_name" name="tld_name" required>
|
||||||
|
<label for="info_site">Info Site:</label>
|
||||||
|
<input type="text" id="info_site" name="info_site" required>
|
||||||
|
<input type="submit" name="create_tld" value="Create TLD">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>Create API Key</h2>
|
||||||
|
<form method="post">
|
||||||
|
<label for="application">Application:</label>
|
||||||
|
<input type="text" id="application" name="application" required>
|
||||||
|
<input type="submit" name="create_apikey" value="Create API Key">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>Delete Account</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="submit" name="delete_account" value="Delete Account">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
40
frontend/index.php
Normal file
40
frontend/index.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
include(__DIR__ . "/utils/connection.php");
|
||||||
|
include(__DIR__ . "/utils/functions.php");
|
||||||
|
|
||||||
|
global $con;
|
||||||
|
$user_data = check_login($con);
|
||||||
|
|
||||||
|
if ($user_data != null) {
|
||||||
|
header('Location: dashboard.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Open Autonomous Connection - Management</title>
|
||||||
|
<meta name="charset" content="UTF-8" />
|
||||||
|
<meta name="author" content="Open Autonomous Connection" />
|
||||||
|
<meta name="description" content="Register here your API Key or (Top level) Domain" />
|
||||||
|
<meta name="keywords" content="domain,api,oac,registration,key,host,manager,management" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="auth/register.php">Register</a>
|
||||||
|
<a href="auth/login.php">Login</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
17
frontend/utils/connection.php
Normal file
17
frontend/utils/connection.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include(__DIR__ . "/../config.php");
|
||||||
|
|
||||||
|
global $DATABASE_HOST, $DATABASE_USER, $DATABASE_PASSWORD, $DATABASE_NAME;
|
||||||
|
|
||||||
|
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASSWORD, $DATABASE_NAME);
|
||||||
|
if (!$con) echo "Failed to connect";
|
||||||
|
?>
|
||||||
449
frontend/utils/functions.php
Normal file
449
frontend/utils/functions.php
Normal file
@@ -0,0 +1,449 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$DOMAIN_PATTERN = '/^(?!-)[A-Za-z0-9-]{1,63}(?<!-)$/';
|
||||||
|
$TOP_LEVEL_DOMAIN_PATTERN = '/^[A-Za-z]{2,6}$/';
|
||||||
|
|
||||||
|
function check_login($con) {
|
||||||
|
if (isset($_SESSION["user"]) && isset($_SESSION["pass"])) {
|
||||||
|
$user = $_SESSION["user"];
|
||||||
|
$pass = $_SESSION["pass"];
|
||||||
|
|
||||||
|
if (!username_exists($con, $user)) {
|
||||||
|
logout();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "SELECT * FROM accounts WHERE username = '$user' AND password = '$pass'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
if ($result && mysqli_num_rows($result) > 0) {
|
||||||
|
if (!login($con, $user, $pass, true)) {
|
||||||
|
logout();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_data = mysqli_fetch_assoc($result);
|
||||||
|
return $user_data && login($con, $user, $pass, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
unset($_SESSION["user"]);
|
||||||
|
unset($_SESSION["pass"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_domains($con, $username) {
|
||||||
|
$domains = [];
|
||||||
|
|
||||||
|
// Get the infokeys for the domains associated with the user
|
||||||
|
$query = "SELECT infokey FROM accountinfos WHERE username = ? AND type = 'domain'";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
|
||||||
|
$infokeys = [];
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$infokeys[] = $row['infokey'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the domains based on the infokeys
|
||||||
|
if (!empty($infokeys)) {
|
||||||
|
$placeholders = implode(',', array_fill(0, count($infokeys), '?'));
|
||||||
|
$types = str_repeat('s', count($infokeys));
|
||||||
|
|
||||||
|
$query = "SELECT * FROM domains WHERE accesskey IN ($placeholders)";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
|
||||||
|
// Dynamically bind the parameters
|
||||||
|
mysqli_stmt_bind_param($stmt, $types, ...$infokeys);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
|
||||||
|
$domains = mysqli_fetch_all($result, MYSQLI_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_topleveldomains($con, $username) {
|
||||||
|
$query = "SELECT infokey FROM accountinfos WHERE username = ? AND type = 'tld'";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
|
||||||
|
$tlds = [];
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$infokey = $row['infokey'];
|
||||||
|
$query = "SELECT * FROM topleveldomains WHERE accesskey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $infokey);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result_tld = mysqli_stmt_get_result($stmt);
|
||||||
|
$tlds = array_merge($tlds, mysqli_fetch_all($result_tld, MYSQLI_ASSOC));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tlds;
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_apikeys($con, $username) {
|
||||||
|
$query = "SELECT infokey FROM accountinfos WHERE username = ? AND type = 'api'";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
|
||||||
|
$apikeys = [];
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$infokey = $row['infokey'];
|
||||||
|
$query = "SELECT * FROM apikeys WHERE keyapi = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $infokey);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result_apikey = mysqli_stmt_get_result($stmt);
|
||||||
|
$apikeys = array_merge($apikeys, mysqli_fetch_all($result_apikey, MYSQLI_ASSOC));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $apikeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_domain($con, $name, $topLevelDomain, $destination, $username) {
|
||||||
|
if (!domainRegisteringAllowed($con)) return false;
|
||||||
|
if (domain_exists($con, $name, $topLevelDomain)) return false;
|
||||||
|
if (strlen($name) < 3 || strlen($name) > 20) return false;
|
||||||
|
if (!top_level_domain_exists($con, $topLevelDomain)) return false;
|
||||||
|
if (!is_valid_domain($name)) return false;
|
||||||
|
if (!is_valid_top_level_domain($topLevelDomain)) return false;
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
|
||||||
|
$access_key = generate_key($name . "." . $topLevelDomain . "=" . $username);
|
||||||
|
$query = "INSERT INTO domains (name, topleveldomain, destination, accesskey) VALUES (?, ?, ?, ?)";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ssss', $name, $topLevelDomain, $destination, $access_key);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$query = "INSERT INTO accountinfos (username, infokey, type) VALUES (?, ?, 'domain')";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ss', $username, $access_key);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_top_level_domain($con, $name, $infoSite, $username) {
|
||||||
|
if (!topLevelDomainRegisteringAllowed($con)) return false;
|
||||||
|
if (strlen($name) < 3 || strlen($name) > 10) return false;
|
||||||
|
if (top_level_domain_exists($con, $name)) return false;
|
||||||
|
if (!is_valid_top_level_domain($name)) return false;
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
|
||||||
|
$access_key = generate_key($infoSite . "." . $name . "=" . $username);
|
||||||
|
$query = "INSERT INTO topleveldomains (name, accesskey, info) VALUES (?, ?, ?)";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'sss', $name, $access_key, $infoSite);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$query = "INSERT INTO accountinfos (username, infokey, type) VALUES (?, ?, 'tld')";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ss', $username, $access_key);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_api_key($con, $username, $application) {
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
if (has_api_key($con, $username, $application)) return false;
|
||||||
|
|
||||||
|
$currentApiKeyCount = getCurrentApiKeyCount($con, $username);
|
||||||
|
$maxApiKeyCount = maxApiKeys($con);
|
||||||
|
|
||||||
|
if ($maxApiKeyCount != -1 && $currentApiKeyCount >= $maxApiKeyCount) return false;
|
||||||
|
|
||||||
|
$apikey = generate_key($username . "=" . $application);
|
||||||
|
$query = "INSERT INTO apikeys (username, application, keyapi) VALUES (?, ?, ?)";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'sss', $username, $application, $apikey);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$query = "INSERT INTO accountinfos (username, infokey, type) VALUES (?, ?, 'api')";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ss', $username, $apikey);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentApiKeyCount($con, $username) {
|
||||||
|
$query = "SELECT COUNT(*) as count FROM apikeys WHERE username = '$username'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
if ($result && $row = mysqli_fetch_assoc($result)) {
|
||||||
|
return intval($row['count']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_valid_domain(string $name) {
|
||||||
|
global $DOMAIN_PATTERN;
|
||||||
|
return preg_match($DOMAIN_PATTERN, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_valid_top_level_domain(string $topLevelDomain) {
|
||||||
|
global $TOP_LEVEL_DOMAIN_PATTERN;
|
||||||
|
return preg_match($TOP_LEVEL_DOMAIN_PATTERN, $topLevelDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_domain_access_key($con, $name, $topLevelDomain, $accessKey) {
|
||||||
|
$query = "SELECT * FROM domains WHERE name = '$name' AND topleveldomain = '$topLevelDomain' AND accesskey = '$accessKey'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_top_level_domain_access_key($con, $topLevelDomain, $accessKey) {
|
||||||
|
$query = "SELECT * FROM topleveldomains WHERE name = '$topLevelDomain' AND accesskey = '$accessKey'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function domain_exists($con, $name, $topLevelDomain) {
|
||||||
|
if (strcasecmp($name, "info") == 0) return true;
|
||||||
|
|
||||||
|
$query = "SELECT * FROM domains WHERE name = '$name' AND topleveldomain = '$topLevelDomain'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function top_level_domain_exists($con, $topLevelDomain) {
|
||||||
|
if (strcasecmp($topLevelDomain, "oac") == 0) return true;
|
||||||
|
$query = "SELECT * FROM topleveldomains WHERE name = '$topLevelDomain'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_api_key($con, $username, $application, $apikey) {
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
if (!has_api_key($con, $username, $application)) return false;
|
||||||
|
|
||||||
|
$query = "SELECT * FROM apikeys WHERE application = '$application' AND keyapi = '$apikey' AND username = '$username'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function has_api_key($con, $username, $application) {
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
|
||||||
|
$query = "SELECT * FROM apikeys WHERE application = '$application' AND username = '$username'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function username_exists($con, $username) {
|
||||||
|
$query = "SELECT * FROM accounts WHERE username = '$username'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_account($con, $username, $password) {
|
||||||
|
if (!accountRegisteringAllowed($con)) return false;
|
||||||
|
if (username_exists($con, $username)) return false;
|
||||||
|
$pw = hash('sha512', $password);
|
||||||
|
|
||||||
|
$query = "INSERT INTO accounts (username, password) VALUES (?, ?)";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ss', $username, $pw);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function login($con, $username, $password, $sha = false) {
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
$pw = $password;
|
||||||
|
if (!$sha) $pw = hash('sha512', $password);
|
||||||
|
|
||||||
|
$query = "SELECT * FROM accounts WHERE username = '$username' AND password = '$pw'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
return $result && mysqli_num_rows($result) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_key($based) {
|
||||||
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
$charactersLength = strlen($characters);
|
||||||
|
$randomString = '';
|
||||||
|
for ($i = 0; $i < 20; $i++) $randomString .= $characters[random_int(0, $charactersLength - 1)];
|
||||||
|
|
||||||
|
return hash("sha512", $based . $randomString);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_api_key($con, $username, $application, $apiKey) {
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
if (!has_api_key($con, $username, $application)) return false;
|
||||||
|
if (!validate_api_key($con, $username, $application, $apiKey)) return false;
|
||||||
|
|
||||||
|
$query = "DELETE FROM apikeys WHERE application = ? AND keyapi = ? AND username = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'sss', $application, $apiKey, $username);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$query = "DELETE FROM accountinfos WHERE username = ? AND infokey = ? AND type = 'api'";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ss', $username, $apiKey);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_domain($con, $name, $topLevelDomain, $accessKey) {
|
||||||
|
if (!validate_domain_access_key($con, $name, $topLevelDomain, $accessKey)) return false;
|
||||||
|
|
||||||
|
$query = "DELETE FROM domains WHERE name = ? AND topleveldomain = ? AND accesskey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'sss', $name, $topLevelDomain, $accessKey);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$query = "DELETE FROM accountinfos WHERE infokey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $accessKey);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_top_level_domain($con, $topLevelDomain, $accessKey) {
|
||||||
|
if (!validate_top_level_domain_access_key($con, $topLevelDomain, $accessKey)) return false;
|
||||||
|
|
||||||
|
$query = "DELETE FROM topleveldomains WHERE name = ? AND accesskey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 'ss', $topLevelDomain, $accessKey);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$query = "DELETE FROM accountinfos WHERE infokey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $accessKey);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_account($con, $username) {
|
||||||
|
if (!username_exists($con, $username)) return false;
|
||||||
|
|
||||||
|
$query = "SELECT infokey FROM accountinfos WHERE username = ? AND type = 'domain'";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$infokey = $row['infokey'];
|
||||||
|
$query = "DELETE FROM domains WHERE accesskey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $infokey);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "SELECT infokey FROM accountinfos WHERE username = ? AND type = 'tld'";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
$result = mysqli_stmt_get_result($stmt);
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$infokey = $row['infokey'];
|
||||||
|
$query = "DELETE FROM topleveldomains WHERE accesskey = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $infokey);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "DELETE FROM apikeys WHERE username = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
$query = "DELETE FROM accountinfos WHERE username = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
$query = "DELETE FROM accounts WHERE username = ?";
|
||||||
|
$stmt = mysqli_prepare($con, $query);
|
||||||
|
mysqli_stmt_bind_param($stmt, 's', $username);
|
||||||
|
$result = mysqli_stmt_execute($stmt);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfigValue($con, $name) {
|
||||||
|
$query = "SELECT value FROM config WHERE name = '$name'";
|
||||||
|
$result = mysqli_query($con, $query);
|
||||||
|
|
||||||
|
if ($result && $row = mysqli_fetch_assoc($result)) {
|
||||||
|
return $row['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseBoolean($value) {
|
||||||
|
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
function topLevelDomainRegisteringAllowed($con) {
|
||||||
|
$value = getConfigValue($con, 'allow_register_tld');
|
||||||
|
return $value !== null && parseBoolean(intval($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function domainRegisteringAllowed($con) {
|
||||||
|
$value = getConfigValue($con, 'allow_register_domain');
|
||||||
|
return $value !== null && parseBoolean(intval($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function accountRegisteringAllowed($con) {
|
||||||
|
$value = getConfigValue($con, 'allow_register_account');
|
||||||
|
return $value !== null && parseBoolean(intval($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function maxApiKeys($con) {
|
||||||
|
$value = getConfigValue($con, 'max_apikeys');
|
||||||
|
return $value !== null ? intval($value) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
11
frontend/utils/index.php
Normal file
11
frontend/utils/index.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
|
||||||
|
You are unauthorized to remove this copyright.
|
||||||
|
You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
See LICENSE-File if exists
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
header('Location: index.php');
|
||||||
|
?>
|
||||||
194
open_autonomous_connection.sql
Normal file
194
open_autonomous_connection.sql
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 5.1.1deb5ubuntu1
|
||||||
|
-- https://www.phpmyadmin.net/
|
||||||
|
--
|
||||||
|
-- Host: localhost:3306
|
||||||
|
-- Erstellungszeit: 09. Jul 2024 um 13:40
|
||||||
|
-- Server-Version: 10.6.18-MariaDB-0ubuntu0.22.04.1
|
||||||
|
-- PHP-Version: 8.1.2-1ubuntu2.18
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
START TRANSACTION;
|
||||||
|
SET time_zone = "+00:00";
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8mb4 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Datenbank: `open_autonomous_connection`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `accountinfos`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `accountinfos` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`username` varchar(255) NOT NULL,
|
||||||
|
`infokey` varchar(255) NOT NULL,
|
||||||
|
`type` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `accounts`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `accounts` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`username` varchar(255) NOT NULL,
|
||||||
|
`password` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `apikeys`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `apikeys` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`application` varchar(255) NOT NULL,
|
||||||
|
`keyapi` varchar(255) NOT NULL,
|
||||||
|
`username` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `config`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `config` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`name` varchar(255) NOT NULL,
|
||||||
|
`value` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Daten für Tabelle `config`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `config` (`id`, `name`, `value`) VALUES
|
||||||
|
(1, 'allow_register_tld', '1'),
|
||||||
|
(2, 'allow_register_domain', '1'),
|
||||||
|
(3, 'allow_register_account', '1'),
|
||||||
|
(4, 'max_apikeys', '5');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `domains`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `domains` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`name` varchar(255) NOT NULL,
|
||||||
|
`topleveldomain` varchar(255) NOT NULL,
|
||||||
|
`destination` varchar(255) NOT NULL,
|
||||||
|
`accesskey` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Tabellenstruktur für Tabelle `topleveldomains`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `topleveldomains` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`name` varchar(255) NOT NULL,
|
||||||
|
`accesskey` varchar(255) NOT NULL,
|
||||||
|
`info` varchar(255) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes der exportierten Tabellen
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `accountinfos`
|
||||||
|
--
|
||||||
|
ALTER TABLE `accountinfos`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `accounts`
|
||||||
|
--
|
||||||
|
ALTER TABLE `accounts`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `apikeys`
|
||||||
|
--
|
||||||
|
ALTER TABLE `apikeys`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `config`
|
||||||
|
--
|
||||||
|
ALTER TABLE `config`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `domains`
|
||||||
|
--
|
||||||
|
ALTER TABLE `domains`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indizes für die Tabelle `topleveldomains`
|
||||||
|
--
|
||||||
|
ALTER TABLE `topleveldomains`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für exportierte Tabellen
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `accountinfos`
|
||||||
|
--
|
||||||
|
ALTER TABLE `accountinfos`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `accounts`
|
||||||
|
--
|
||||||
|
ALTER TABLE `accounts`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `apikeys`
|
||||||
|
--
|
||||||
|
ALTER TABLE `apikeys`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `config`
|
||||||
|
--
|
||||||
|
ALTER TABLE `config`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `domains`
|
||||||
|
--
|
||||||
|
ALTER TABLE `domains`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT für Tabelle `topleveldomains`
|
||||||
|
--
|
||||||
|
ALTER TABLE `topleveldomains`
|
||||||
|
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
15
pom.xml
15
pom.xml
@@ -5,8 +5,8 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.openautonomousconnection</groupId>
|
<groupId>org.openautonomousconnection</groupId>
|
||||||
<artifactId>DNSServer</artifactId>
|
<artifactId>INSServer</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-CLASSIC</version>
|
||||||
<organization>
|
<organization>
|
||||||
<name>Open Autonomous Connection</name>
|
<name>Open Autonomous Connection</name>
|
||||||
<url>https://open-autonomous-connection.org/</url>
|
<url>https://open-autonomous-connection.org/</url>
|
||||||
@@ -45,13 +45,13 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>Issue Tracker</system>
|
<system>Issue Tracker</system>
|
||||||
<url>https://repo.open-autonomous-connection.org/open-autonomous-connection/DNSServer/issues</url>
|
<url>https://repo.open-autonomous-connection.org/open-autonomous-connection/INSServer/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>Open Autonomous Public License</name>
|
<name>Open Autonomous Public License</name>
|
||||||
<url>https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/OAPL/</url>
|
<url>https://open-autonomous-connection.org/license.html</url>
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
@@ -70,7 +70,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openautonomousconnection</groupId>
|
<groupId>org.openautonomousconnection</groupId>
|
||||||
<artifactId>protocol</artifactId>
|
<artifactId>protocol</artifactId>
|
||||||
<version>1.0.0-BETA.7</version>
|
<version>1.0.0-CLASSIC</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>5.1.39</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQC9Uu9/sNevUGr1
|
|
||||||
k6LI5jdI/HAbsgaS2eFat0mdPKhD0IrDMozhZ1zDh6w/4iOhNC6ypwy0+1l/r6cT
|
|
||||||
6xL2s3x+DxoaeskMpRD4kd97cE7YrvxXMSwFj5exVnyps03QXFQigZryW5z26xyF
|
|
||||||
Jw3i6XiHkhpz1fwMKBXynkUROy5IuZu5oTsNko+dcjZWtOI9Tnf0HqmEW8Jrhpjw
|
|
||||||
JnZX8HBs0Ydd+gr7/nITLF6Eq0Gd1uRupsAOSsZfdXofqgxfVy5CsAyfK/163cnL
|
|
||||||
BZ5ynKMzqyhxS/9wLQfBLq6499e8w5+5/WHPIZLFeVOfdunudEFmE5aQwjnNBESI
|
|
||||||
EyaaYlhXQdKhTnAU2JYEg4pnp43DXMxsPeDY/OXDoQAJbuj1ip6jFwIyt8cj6uGv
|
|
||||||
diFrY1Nqa1Ua2Y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aXyFjzp42roqV5Kn2LcOi4y66crNkTYGEUN6v70+gcg0OlclkIka05UI
|
|
||||||
FpEQIQybWU87XWFr71gDHxV2UnWvyOl2tAuMIOkHxsdaAOFusIvWU09nNbeOO33l
|
|
||||||
9QfmwFz7U4QgvfOrm49tdncD1BCaGRijTwPxUFsBAoIBAEpWikSYn3CJalPdwtd3
|
|
||||||
qhKzIQ5BO5p8C1bPV6hoixWTgczeapCDlj1pLNs8BFHONB9Jxyx5z3KIYxrJ55dk
|
|
||||||
wKrNwrEXTBQ153fDcdNL1aacEVTbZRk9jArz3ganMZrQdqJLnaKwQjIPOnhz9lQB
|
|
||||||
brB+8Xs1GgzKr8YtLaJk9NJrnTqI8XlnOOTBg3H+/ahwBjMjPGPtTkzaLXr4ALO8
|
|
||||||
3wlnjpjq9fsjLPMAdlszeETjX4CeL260c+cvhpuHrXCOlfgE5lPcF10Av9/6Hjlo
|
|
||||||
Nl22DvdanwdpszVoiy4OoPPbV9efT+2YU9vQOGp17pJUWMXb4ys/Q7WcJ55a9gI9
|
|
||||||
g0cCggEBAL+B6vL4ipi9ioGCePPC4Klew/GTxy3dqJtCw7woHlz76zHJsQqllY8S
|
|
||||||
wqzcydRvvpkxI8HGNWtMSGiPWePss7qUrAdq0jZh921buXtuD3aqqUjaLDnm3rYz
|
|
||||||
v844JFJyKhgUqwkXHOeOw9ktsMxpBOsqa0vcYVmZ2dalvFC47b3pHplJmATLgV/6
|
|
||||||
lCHUXi5HZ53Yd5lyduUuavnWuWnnwbovc4vKBz7zMHb70oQSn/6wx5f7Bbgy1ZSk
|
|
||||||
7vlNYomNKgl5dtRlphBi3GFxyrE5EDFzis6UX7lNjADZrqYSeBCT8EFBoEfc/eVN
|
|
||||||
c5RF/V4VtgM7jggSLlUUgO0L2/Hw5bM=
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIEvAIBADANBgkqhkiG9w0B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||||||
o6QbLsjEqISAOxipLRTZhQjvePzSD4Y4F7jKqNcvK6LZnQiE43C6VImMT8UT7C2a
|
|
||||||
ht96l3/bDEGEls1HrzqVVepCWQGnKltkOU69HDRYXJCGJwZ5hfx66UtsXR0ICSNH
|
|
||||||
EHBoZE3qLQKBgAx4Xfjeg+79F/4qbhAq9a67ActAPm/vEfjIUWWeW2kXlO0ynJZI
|
|
||||||
ai5/KlgEDcI0bcMZ5xMuNuXFbD1rovPPJF28TyECUyFwLqqQggVL5/lObAt7DJvV
|
|
||||||
+YQ5OryyjNyaMOpVB/cKf050z4OqoqZ8Rr1MmMi+qvB+4RedBSUaX3+pAoGACwbM
|
|
||||||
R6q4T0EY+TKQuETXC6ykFZoBV109hR8qEyW8gWPAZxkg5Br5f/XfDtAf6z1aO8fP
|
|
||||||
Fuz3zq3A0Vf8xlQAzGF4xpWNpR8bqnwcpmqfDSuyToXkRkBGM94qXUSMQLzbMSXr
|
|
||||||
eolQ52bAjAOQ83n6GC4Qf60gqvZA0WI+FT7JGRECgYAi54HhK7HFogAlX58EX77h
|
|
||||||
YHL5KHBlG+l8v4amIKvD0JclYylwyLhYkmIM+T4mh8I+T1nabcNeNWit+CYoLwQ8
|
|
||||||
A3P0ij67TkEV3Ud7KKOtYty+getkM9/hwm14LlMzfLZKay9HCsbb5E2TgmShF68F
|
|
||||||
VtECuunYyfN4wJSE0aWRPg==
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIFazCCA1OgAwIBAgIUQ67NCnk5KBqDD7fHdzKVi+AfRR8wDQYJKoZIhvcNAQEL
|
|
||||||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
|
||||||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNTA5MjExMTU2NTlaFw0zNTA5
|
|
||||||
MTkxMTU2NTlaME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TAQH/BAUwAwEB/zANBgkq
|
|
||||||
hkiG9w0BAQsFAAOCAgEAAV1Mafun3XwC2cs4Xgq1vzJw69I24y8dXm45qFdLl5Vv
|
|
||||||
hkIecwDm2+Ongg82sPPmR1TwsRgdUytywal5nsa1aH/v70MJ7Ic5pBIXdv54kZ8v
|
|
||||||
qgaItmHF+twb+aqFz/NY0BMv7nNc2MyYEyDwbJUIGwGt+yOlQfHUIwNc+PvVL6Sn
|
|
||||||
mkm7//EIfiU3HxmusCnbYC+9kmLbeds10qDzTNIHP4ffNAFgnMgauNID8X9RoPBT
|
|
||||||
TVqLjD5WDHridLMF8n0m18cp2MqV33gXbg4pT/rYvh40p9jJuGDJbcrn5WtKvbMn
|
|
||||||
lm27oI6bcwKF2i+VHRBxW/c/DZaG0QKo4PaDCd/kF2ix1ymkFG4MtvHmu0Q3SLXi
|
|
||||||
p7fTL4WZSEUPXe/E7fUuPwof54auXLYNhSR9HJo0ZS2R0S9pursBkBEXTXyiG8T+
|
|
||||||
iUq4VtBny1Ylr2rJ8Qr1TiaB5ud/IeEv70uDgA9XyUhikfs7t5bYrqdXjANtCvZY
|
|
||||||
j322+I3wyDdosu2Z1Lrn2w95ZyJhc/rluftc1lKnxgYwKndEJfBlhn8tpHlk2J9T
|
|
||||||
rPqAezvNhSXH1W6G7WZAvHfdfJahLDhfJ15YQcqqPK+DXEaJeOnUompV+/MEaEOE
|
|
||||||
3LwN4B78mTgVOcabMeo1NN/2nGObaOm/62t+3B9NwcUi9q1LT/oifLVBh8bEFug=
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
5FB2F5A2CA8357D37C84CC406B5F81617348EB58
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEWjCCAkKgAwIBAgIUX7L1osqDV9N8hMxAa1+BYXNI61gwDQYJKoZIhvcNAQEL
|
|
||||||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgN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||||
IPikKx9Gt8EpwT+ytJKOnd/A7nBEiaDw5ubcR1s6pmlcGLAE1+A9TX2ncRUcvMI4
|
|
||||||
w2M5i7X/Vz2zQiPEWmQliYDG1ZFeD1dth973muM6H6NvFyXvEzzRZl5K5DwAcgqA
|
|
||||||
uMvEKDiDPwKROBTzjq3WIHBe49fz96Fpxld5JxH3RhC2PzIYjUquU2P8Ah6SN6SZ
|
|
||||||
+Mf/61QxNInnEcxNjknGhcfiyhoqu2B+1/N5cfpXyBfgTQfVzV3HiUvAHzcza9yp
|
|
||||||
mnPrrxRodkXwncMJNJYTr36yTyZPxC0TZUycvOPwEfBQ1vESAeiJ7+QgFGFu0lgQ
|
|
||||||
1XAJVpCfHpDrkT184/pszyHHzydWvP7GcrPgJVNlXbMvpenhm2QTCaft5TUDj9+m
|
|
||||||
8quLjm+bj0OQq1Fmv/OlWvycC5fxnYA0JlRDz56QPHkEL7aZ/+apZhB6Eb77/etv
|
|
||||||
A5go7PJCZ9vnblPW/HE=
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#Sat Oct 04 01:25:22 CEST 2025
|
|
||||||
server.site.info=DNS-SERVER INFO SITE IP
|
|
||||||
server.site.register=SERVER IP TO DNS-FRONTENT WEBSITE
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package org.openautonomousconnection.dns;
|
|
||||||
|
|
||||||
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
|
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerDNSServer;
|
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
|
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
|
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class ClassicHandler extends ClassicHandlerDNSServer {
|
|
||||||
@Override
|
|
||||||
public void handleMessage(ConnectedProtocolClient client, String message, Classic_ProtocolVersion protocolVersion) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Classic_Domain getDomain(Classic_RequestDomain requestDomain) throws SQLException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Classic_Domain ping(Classic_RequestDomain requestDomain) throws SQLException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unsupportedClassicPacket(String className, Object[] content, ConnectedProtocolClient client) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openautonomousconnection.dns;
|
||||||
|
|
||||||
|
import org.openautonomousconnection.dns.utils.Database;
|
||||||
|
import org.openautonomousconnection.protocol.domain.Domain;
|
||||||
|
import org.openautonomousconnection.protocol.domain.RequestDomain;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DomainManager {
|
||||||
|
|
||||||
|
public static Domain getDomain(String name, String topLevelDomain) throws SQLException {
|
||||||
|
for (Domain domain : getDomains())
|
||||||
|
if (domain.name.equalsIgnoreCase(name) && domain.topLevelDomain.equalsIgnoreCase(topLevelDomain))
|
||||||
|
return domain;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Domain getDomain(RequestDomain requestDomain) throws SQLException {
|
||||||
|
return getDomain(requestDomain.name, requestDomain.topLevelDomain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Domain> getDomains() throws SQLException {
|
||||||
|
List<Domain> domains = new ArrayList<>();
|
||||||
|
|
||||||
|
ResultSet result = Database.getConnection().prepareStatement("SELECT name, topleveldomain, destination FROM domains").executeQuery();
|
||||||
|
while (result.next()) {
|
||||||
|
String name = result.getString("name");
|
||||||
|
String topLevelDomain = result.getString("topleveldomain");
|
||||||
|
String destination = result.getString("destination");
|
||||||
|
domains.add(new Domain(name, topLevelDomain, destination, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
return domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getTopLevelDomains() throws SQLException {
|
||||||
|
List<String> topLevelDomains = new ArrayList<>();
|
||||||
|
|
||||||
|
ResultSet result = Database.getConnection().prepareStatement("SELECT name FROM topleveldomains").executeQuery();
|
||||||
|
while (result.next()) topLevelDomains.add(result.getString("name"));
|
||||||
|
return topLevelDomains;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package org.openautonomousconnection.dns;
|
|
||||||
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.command.events.CommandExecutorMissingPermissionEvent;
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.command.events.CommandNotFoundEvent;
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
|
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
|
|
||||||
public class Listener extends EventListener {
|
|
||||||
|
|
||||||
@dev.unlegitdqrk.unlegitlibrary.event.Listener
|
|
||||||
public void onCommandNotFound(CommandNotFoundEvent event) {
|
|
||||||
StringBuilder argsBuilder = new StringBuilder();
|
|
||||||
for (String arg : event.getArgs()) argsBuilder.append(arg).append(" ");
|
|
||||||
ProtocolBridge.getInstance().getLogger().error("Command '" + event.getName() + argsBuilder.toString() + "' not found!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@dev.unlegitdqrk.unlegitlibrary.event.Listener
|
|
||||||
public void onMissingCommandPermission(CommandExecutorMissingPermissionEvent event) {
|
|
||||||
ProtocolBridge.getInstance().getLogger().error("You do not have enough permissions to execute this command!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
package org.openautonomousconnection.dns;
|
package org.openautonomousconnection.dns;
|
||||||
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor;
|
import dev.unlegitdqrk.unlegitlibrary.addon.AddonLoader;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.command.CommandManager;
|
import dev.unlegitdqrk.unlegitlibrary.addon.impl.AddonInfo;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.command.CommandPermission;
|
import org.openautonomousconnection.dns.utils.Config;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.utils.Logger;
|
import org.openautonomousconnection.dns.utils.Database;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||||
import org.openautonomousconnection.protocol.ProtocolSettings;
|
import org.openautonomousconnection.protocol.ProtocolSettings;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.ProtocolVersion;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.cert.CertificateException;
|
import java.io.InputStreamReader;
|
||||||
import java.util.Scanner;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static final CommandPermission PERMISSION_ALL = new CommandPermission("all", 1);
|
public static ProtocolBridge protocolBridge;
|
||||||
private static final CommandExecutor commandExecutor = new CommandExecutor("DNS", PERMISSION_ALL) {};
|
public static AddonLoader addonLoader;
|
||||||
private static CommandManager commandManager;
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static final File modulesFolder = new File("modules");
|
||||||
ProtocolSettings settings = new ProtocolSettings();
|
|
||||||
new ProtocolBridge(new Server(), settings, ProtocolVersion.PV_1_0_0_BETA, new File("logs"));
|
|
||||||
ProtocolBridge.getInstance().setClassicHandlerDNSServer(new ClassicHandler());
|
|
||||||
commandManager = new CommandManager(ProtocolBridge.getInstance().getProtocolSettings().eventManager);
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
|
|
||||||
while (true) {
|
public static void main(String[] args) {
|
||||||
System.out.println(commandExecutor.getName() + "> ");
|
try {
|
||||||
String line = scanner.nextLine();
|
URL oracle = new URI("https://raw.githubusercontent.com/Open-Autonomous-Connection/dns/master/src/resources/version.txt").toURL();
|
||||||
commandManager.execute(commandExecutor, line);
|
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
|
||||||
|
StringBuilder version = new StringBuilder();
|
||||||
|
String inputLine;
|
||||||
|
while ((inputLine = in.readLine()) != null) version.append(inputLine);
|
||||||
|
|
||||||
|
if (!version.toString().equalsIgnoreCase(Files.readString(Path.of(Objects.requireNonNull(Main.class.getResource("../../../version.txt")).toURI())))) {
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("======================================================");
|
||||||
|
System.out.println("IMPORTANT: A NEW SERVER VERSION IS PUBLISHED ON GITHUB");
|
||||||
|
System.out.println("======================================================");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
} catch (IOException | URISyntaxException exception) {
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("=====================================================================");
|
||||||
|
System.out.println("IMPORTANT: SERVER VERSION CHECK COULD NOT COMPLETED! VISIT OUR GITHUB");
|
||||||
|
System.out.println(" https://github.com/Open-Autonomous-Connection ");
|
||||||
|
System.out.println("=====================================================================");
|
||||||
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Config.init();
|
||||||
|
Database.connect();
|
||||||
|
} catch (SQLException | InstantiationException | ClassNotFoundException | IllegalAccessException | IOException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ProtocolSettings protocolSettings = new ProtocolSettings();
|
||||||
|
protocolSettings.port = Config.getPort();
|
||||||
|
|
||||||
|
try {
|
||||||
|
protocolBridge = new ProtocolBridge(ProtocolVersion.PV_1_0_0, protocolSettings, new Server());
|
||||||
|
protocolBridge.getProtocolServer().setProtocolBridge(protocolBridge);
|
||||||
|
protocolBridge.getProtocolServer().getServer().getEventManager().registerListener(ServerEventListener.class);
|
||||||
|
protocolBridge.getProtocolServer().startServer();
|
||||||
|
System.out.println();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
try {
|
||||||
|
protocolBridge.getProtocolServer().stopServer();
|
||||||
|
Database.close();
|
||||||
|
} catch (SQLException | IOException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
addonLoader = new AddonLoader(protocolSettings.eventManager, null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
addonLoader.loadAddonsFromDirectory(modulesFolder);
|
||||||
|
addonLoader.getLoadedAddons().forEach(addon -> {
|
||||||
|
if (addon.isEnabled()) return;
|
||||||
|
AddonInfo info = addon.getAddonInfo();
|
||||||
|
System.out.println("Enabling Addon '" + info.name() + " v" + info.version() + "' by " + info.author() + "...");
|
||||||
|
addon.enable();
|
||||||
|
System.out.println("Addon '" + info.name() + " v" + info.version() + "' enabled.");
|
||||||
|
});
|
||||||
|
} catch (IOException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,64 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
package org.openautonomousconnection.dns;
|
package org.openautonomousconnection.dns;
|
||||||
|
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||||
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
|
import org.openautonomousconnection.dns.utils.Config;
|
||||||
import org.openautonomousconnection.protocol.side.dns.ProtocolDNSServer;
|
import org.openautonomousconnection.dns.utils.Database;
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
import org.openautonomousconnection.protocol.domain.Domain;
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
import org.openautonomousconnection.protocol.side.ProtocolServer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.sql.ResultSet;
|
||||||
import java.io.IOException;
|
import java.sql.SQLException;
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Server extends ProtocolDNSServer {
|
public class Server extends ProtocolServer {
|
||||||
/**
|
@Override
|
||||||
* Constructs a ProtocolDNSServer with the specified configuration file.
|
public List<Domain> getDomains() throws SQLException {
|
||||||
*
|
return DomainManager.getDomains();
|
||||||
* @throws IOException If an I/O error occurs.
|
|
||||||
* @throws CertificateException If a certificate error occurs.
|
|
||||||
*/
|
|
||||||
public Server() throws IOException, CertificateException {
|
|
||||||
super(new File("config.properties"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Domain> getDomains() {
|
public List<String> getTopLevelDomains() throws SQLException {
|
||||||
return List.of();
|
return DomainManager.getTopLevelDomains();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDomainDestination(Domain domain) {
|
public void handleMessage(ConnectionHandler connectionHandler, String message) {
|
||||||
return "";
|
System.out.println("[MESSAGE] " + connectionHandler.getClientID() + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSubnameDestination(Domain domain, String subname) {
|
public String getInfoSite(String topLevelDomain) throws SQLException {
|
||||||
return "";
|
if (!topLevelDomainExists(topLevelDomain)) return null;
|
||||||
|
|
||||||
|
ResultSet resultSet = Database.getConnection().prepareStatement("SELECT name, info FROM topleveldomains").executeQuery();
|
||||||
|
while (resultSet.next()) if (resultSet.getString("name").equals(topLevelDomain)) return resultSet.getString("info");
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTLNInfoSite(String topLevelName) {
|
public String getInterfaceSite() {
|
||||||
return "";
|
return Config.getInterfaceSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DNSResponseCode validateDomain(Domain requestedDomain) {
|
public String getDNSServerInfoSite() {
|
||||||
if (!requestedDomain.getProtocol().equalsIgnoreCase("oac")) return DNSResponseCode.RESPONSE_INVALID_REQUEST;
|
return Config.getInfoSite();
|
||||||
return DNSResponseCode.RESPONSE_DOMAIN_FULLY_NOT_EXIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validationPacketSendFailed(Domain domain, ConnectedProtocolClient client, Exception exception) {
|
|
||||||
ProtocolBridge.getInstance().getLogger().exception("Failed to send ValidationPacket. (" +
|
|
||||||
"Domain: " + domain.getProtocol() + "." + (domain.hasSubname() ? domain.getSubname() : "") + "." + domain.getTopLevelName() + "/" + domain.getPath() + "?" + domain.getQuery() + "#" + domain.getFragment() + ";" +
|
|
||||||
";Client: " + client.getConnectionHandler().getClientID() + ")", exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void domainDestinationPacketFailedSend(ConnectedProtocolClient client, Domain domain, DNSResponseCode validationResponse, Exception exception) {
|
|
||||||
ProtocolBridge.getInstance().getLogger().exception("Failed to send DomainDestinationPacket. (" +
|
|
||||||
"Domain: " + domain.getProtocol() + "." + (domain.hasSubname() ? domain.getSubname() : "") + "." + domain.getTopLevelName() + "/" + domain.getPath() + "?" + domain.getQuery() + "#" + domain.getFragment() + ";" +
|
|
||||||
"Validation response: " + validationResponse + ";Client: " + client.getConnectionHandler().getClientID() + ")", exception);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openautonomousconnection.dns;
|
||||||
|
|
||||||
|
import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
|
||||||
|
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||||
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
||||||
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
||||||
|
import org.openautonomousconnection.protocol.events.v1_0_0.DomainPacketReceivedEvent;
|
||||||
|
import org.openautonomousconnection.protocol.events.v1_0_0.PingPacketReceivedEvent;
|
||||||
|
|
||||||
|
public class ServerEventListener extends EventListener {
|
||||||
|
@Listener
|
||||||
|
public void onConnect(ConnectionHandlerConnectedEvent event) {
|
||||||
|
System.out.println("New client connected. ID: " + event.getConnectionHandler().getClientID());
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onDisconnect(ConnectionHandlerDisconnectedEvent event) {
|
||||||
|
System.out.println("Client disconnected. ID: " + event.getConnectionHandler().getClientID());
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onPing(PingPacketReceivedEvent event) {
|
||||||
|
System.out.println("New Ping request:");
|
||||||
|
System.out.println(" » From client id: " + event.clientID);
|
||||||
|
System.out.println(" » Request domain: " + event.requestDomain.toString());
|
||||||
|
System.out.println(" » Path: " + event.requestDomain.getPath());
|
||||||
|
System.out.println(" » Reachable: " + (event.reachable ? "Yes" : "No"));
|
||||||
|
System.out.println(" » Destination: " + (event.domain == null ? "N/A" : event.domain.parsedDestination()));
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onExistCheck(DomainPacketReceivedEvent event) {
|
||||||
|
System.out.println("New Domain packet request:");
|
||||||
|
System.out.println(" » From client id: " + event.clientID);
|
||||||
|
System.out.println(" » Request domain: " + event.requestDomain.toString());
|
||||||
|
System.out.println(" » Path: " + event.requestDomain.getPath());
|
||||||
|
System.out.println(" » Exists: " + (event.domain == null ? "No" : "Yes"));
|
||||||
|
System.out.println(" » Destination: " + (event.domain == null ? "N/A" : event.domain.parsedDestination()));
|
||||||
|
System.out.println(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openautonomousconnection.dns.utils;
|
||||||
|
|
||||||
|
import org.openautonomousconnection.protocol.utils.APIInformation;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class APIManager {
|
||||||
|
|
||||||
|
public static boolean hasKey(String username, String application) throws SQLException {
|
||||||
|
PreparedStatement statement = Database.getConnection().prepareStatement("SELECT application, username FROM apikeys WHERE application = ? AND username = ?");
|
||||||
|
statement.setString(1, application.toLowerCase());
|
||||||
|
statement.setString(2, username);
|
||||||
|
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return result.next() && result.getString("application").equalsIgnoreCase(application) && result.getString("username").equalsIgnoreCase(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean validateKey(String username, String application, String apiKey) throws SQLException {
|
||||||
|
if (!hasKey(username, application)) return false;
|
||||||
|
|
||||||
|
PreparedStatement statement = Database.getConnection().prepareStatement("SELECT application, keyapi, username FROM apikeys WHERE application = ? AND keyapi = ? AND username = ?");
|
||||||
|
statement.setString(1, application.toLowerCase());
|
||||||
|
statement.setString(2, apiKey);
|
||||||
|
statement.setString(3, username);
|
||||||
|
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return result.next() && result.getString("application").equalsIgnoreCase(application) && result.getString("keyapi").equals(apiKey) && result.getString("username").equalsIgnoreCase(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean validateKey(APIInformation apiInformation) throws SQLException {
|
||||||
|
return validateKey(apiInformation.username, apiInformation.apiApplication, apiInformation.apiKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
116
src/main/java/org/openautonomousconnection/dns/utils/Config.java
Normal file
116
src/main/java/org/openautonomousconnection/dns/utils/Config.java
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openautonomousconnection.dns.utils;
|
||||||
|
|
||||||
|
import dev.unlegitdqrk.unlegitlibrary.file.ConfigurationManager;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
public static boolean parseBoolean(int i) {
|
||||||
|
return i != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int booleanToInt(boolean bool) {
|
||||||
|
return bool ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean topLevelDomainRegisteringAllowed() throws SQLException {
|
||||||
|
PreparedStatement statement = Database.getConnection().prepareStatement("SELECT value FROM config WHERE name = ?");
|
||||||
|
statement.setString(1, "allow_register_tld");
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return result.next() && parseBoolean(Integer.parseInt(result.getString("value")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean domainRegisteringAllowed() throws SQLException {
|
||||||
|
PreparedStatement statement = Database.getConnection().prepareStatement("SELECT value FROM config WHERE name = ?");
|
||||||
|
statement.setString(1, "allow_register_domain");
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return result.next() && parseBoolean(Integer.parseInt(result.getString("value")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean accountRegisteringAllowed() throws SQLException {
|
||||||
|
PreparedStatement statement = Database.getConnection().prepareStatement("SELECT value FROM config WHERE name = ?");
|
||||||
|
statement.setString(1, "allow_register_account");
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
return result.next() && parseBoolean(Integer.parseInt(result.getString("value")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int maxApiKeys() throws SQLException {
|
||||||
|
PreparedStatement statement = Database.getConnection().prepareStatement("SELECT value FROM config WHERE name = ?");
|
||||||
|
statement.setString(1, "max_apikeys");
|
||||||
|
ResultSet result = statement.executeQuery();
|
||||||
|
if (!result.next()) return 0;
|
||||||
|
return Integer.parseInt(result.getString("value")); // -1 = Endless
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final File configFile = new File("./config.properties");
|
||||||
|
private static ConfigurationManager config;
|
||||||
|
public static void init() throws IOException {
|
||||||
|
URL whatIsMyIp = new URL("http://checkip.amazonaws.com");
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(whatIsMyIp.openStream()));
|
||||||
|
|
||||||
|
String ip = in.readLine();
|
||||||
|
|
||||||
|
if (!configFile.exists()) configFile.createNewFile();
|
||||||
|
config = new ConfigurationManager(configFile);
|
||||||
|
config.loadProperties();
|
||||||
|
|
||||||
|
if (!config.isSet("port")) config.set("port", 9382);
|
||||||
|
if (!config.isSet("sites.info")) config.set("sites.info", "DNS SERVER NEED A INFO SITE!");
|
||||||
|
if (!config.isSet("sites.interface")) config.set("sites.interface", ip);
|
||||||
|
if (!config.isSet("database.host")) config.set("database.host", "127.0.0.1");
|
||||||
|
if (!config.isSet("database.port")) config.set("database.port", 3306);
|
||||||
|
if (!config.isSet("database.name")) config.set("database.name", "my_db");
|
||||||
|
if (!config.isSet("database.username")) config.set("database.username", "my_username");
|
||||||
|
if (!config.isSet("database.password")) config.set("database.password", "my_password");
|
||||||
|
|
||||||
|
config.saveProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getInfoSite() {
|
||||||
|
return config.getString("sites.info");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getInterfaceSite() {
|
||||||
|
return config.getString("sites.interface");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPort() {
|
||||||
|
return config.getInt("port");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDatabaseHost() {
|
||||||
|
return config.getString("database.host");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDatabasePort() {
|
||||||
|
return config.getInt("database.port");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDatabaseName() {
|
||||||
|
return config.getString("database.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDatabaseUsername() {
|
||||||
|
return config.getString("database.username");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDatabasePassword() {
|
||||||
|
return config.getString("database.password");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openautonomousconnection.dns.utils;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class Database {
|
||||||
|
|
||||||
|
private static Connection connection;
|
||||||
|
|
||||||
|
public static Connection getConnection() {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void connect() throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
if (isConnected()) return;
|
||||||
|
|
||||||
|
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
||||||
|
connection = DriverManager.getConnection("jdbc:mysql://" + Config.getDatabaseHost() + ":" + Config.getDatabasePort() + "/" +
|
||||||
|
Config.getDatabaseName() + "?autoReconnect=true", Config.getDatabaseUsername(), Config.getDatabasePassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close() throws SQLException {
|
||||||
|
if (!isConnected()) return;
|
||||||
|
|
||||||
|
connection.close();
|
||||||
|
connection = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isConnected() {
|
||||||
|
return connection != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||||
|
*
|
||||||
|
* You are unauthorized to remove this copyright.
|
||||||
|
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||||
|
* See LICENSE-File if exists
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.openautonomousconnection.dns.utils;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static String createAccessKey(String input) {
|
||||||
|
return sha256(shuffleString(sha256(input) + getAlphaNumericString(5) +
|
||||||
|
sha256(getAlphaNumericString(5)) +
|
||||||
|
sha256(getAlphaNumericString(5)) +
|
||||||
|
sha256(getAlphaNumericString(5))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String sha256(final String base) {
|
||||||
|
try {
|
||||||
|
final MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
|
final byte[] hash = digest.digest(base.getBytes(StandardCharsets.UTF_8));
|
||||||
|
final StringBuilder hexString = new StringBuilder();
|
||||||
|
|
||||||
|
for (byte b : hash) {
|
||||||
|
final String hex = Integer.toHexString(0xff & b);
|
||||||
|
if (hex.length() == 1) hexString.append('0');
|
||||||
|
hexString.append(hex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hexString.toString();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAlphaNumericString(int length) {
|
||||||
|
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvxyz";
|
||||||
|
StringBuilder builder = new StringBuilder(length);
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
int index = (int) (chars.length() * Math.random());
|
||||||
|
builder.append(chars.charAt(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String shuffleString(String input) {
|
||||||
|
List<Character> characters = new ArrayList<>();
|
||||||
|
for (char c : input.toCharArray()) characters.add(c);
|
||||||
|
|
||||||
|
Collections.shuffle(characters);
|
||||||
|
StringBuilder shuffledString = new StringBuilder();
|
||||||
|
|
||||||
|
for (char c : characters) shuffledString.append(c);
|
||||||
|
return shuffledString.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
2
src/main/resources/META-INF/MANIFEST.MF
Normal file
2
src/main/resources/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: org.openautonomousconnection.dns.Main
|
||||||
1
src/main/resources/version.txt
Normal file
1
src/main/resources/version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.0
|
||||||
Reference in New Issue
Block a user