Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
korayoezdemir committed Jun 18, 2024
0 parents commit 4859dbf
Show file tree
Hide file tree
Showing 1,452 changed files with 214,538 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Koray

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
docker:
cd deployments && docker compose up -d

docker-down:
cd deployments && docker compose down

postgres-connect:
docker exec -it my-postgres psql -U user mydb

docker-delte-old-volumes:
docker volume prune -f

init-db:
cd deployments && ./init-db.sh

node:
npm start
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Network Configurator Tool

## Overview

The Network Configurator Tool is designed to simplify the process of generating network device configurations, specifically targeting Cisco switches. This tool is ideal for hobbyists, small to medium-sized businesses, and anyone looking to streamline their network setup. It provides a user-friendly web interface to select predefined configuration options, including VLAN setup, IP addressing, and more, ultimately generating a ready-to-apply configuration file.

## Features

- **Class-Based Network Selection**: Choose between Class A, B, or C networks based on the size and requirements of your network.
- **VLAN Configuration Options**: Easily configure VLANs with predefined options for subnet sizes (e.g., 4 VLANs with /24, 8 VLANs with /23).
- **Advanced Network Settings**: Optional settings for routing protocols, DHCP, DNS, NTP server addresses, and security settings like ACLs and port security.
- **Configuration File Generation**: Automatically generates a configuration file based on user inputs, ready for download and application to your device.
- **Step-by-Step Guides**: Provides comprehensive instructions on how to apply the generated configuration to your network device, including methods like TFTP and USB.
- **Feedback and Expansion**: Users can provide feedback and request additional features or device support, enhancing the tool's capabilities and usability.

## Getting Started

### Prerequisites

- A modern web browser.
- Access to the network device(s) for which you are generating a configuration.
- Basic understanding of network concepts and the specific requirements for your network setup.

### Usage

1. **Navigate to the Tool**: Open the tool in your web browser.
2. **Select Network Class**: Choose the appropriate network class (A, B, or C) and specify the starting IP range.
3. **Configure VLANs**: Select from the predefined VLAN configuration options or customize your VLAN settings.
4. **Optional Settings**: Configure advanced settings if needed.
5. **Generate Configuration**: Review your settings and generate the configuration file.
6. **Download and Apply**: Download the generated configuration file and follow the provided instructions to apply it to your device.

## Applying the Configuration

Detailed instructions will be provided with the generated configuration file, including:

- Preparing your network device for configuration.
- Transferring the configuration file to your device (e.g., via TFTP, USB).
- Applying the configuration and verifying its success.
- Troubleshooting common issues.

## License

The Network Configurator Tool is open source and licensed under [MIT License](LICENSE). Feel free to use, modify, and distribute it as per the license terms.
40 changes: 40 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import express, { Express, Request, Response, NextFunction } from "express";
import templateRoutes from "./src/api/routes/templateRoute";
import winston from "winston";

const app: Express = express();
const PORT = process.env.PORT || 3000;

app.use(express.json());

const logger = winston.createLogger({
level: "info",
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: "logs.log" }),
],
});

app.use((req: Request, res: Response, next: NextFunction) => {
logger.info(`Received ${req.method} request for ${req.url}`);
next();
});

app.use("/api/templates", templateRoutes);

app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
logger.error(`Error: ${err.message}`, {
method: req.method,
url: req.url,
errorStack: err.stack,
});
res.status(500).send("Something broke!");
});

app.listen(PORT, () => {
console.log(`Server runs on port ${PORT}`);
});
121 changes: 121 additions & 0 deletions configs/blank-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Current configuration : 1424 bytes
!
version 16.3.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname testswitch
!
!
enable secret 5 $1$mERr$WWYFDFflcd5FpJh6NNHr41
enable password cisco
!
!
!
!
!
!
no ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface GigabitEthernet1/0/1
!
interface GigabitEthernet1/0/2
!
interface GigabitEthernet1/0/3
!
interface GigabitEthernet1/0/4
!
interface GigabitEthernet1/0/5
!
interface GigabitEthernet1/0/6
!
interface GigabitEthernet1/0/7
!
interface GigabitEthernet1/0/8
!
interface GigabitEthernet1/0/9
!
interface GigabitEthernet1/0/10
!
interface GigabitEthernet1/0/11
!
interface GigabitEthernet1/0/12
!
interface GigabitEthernet1/0/13
!
interface GigabitEthernet1/0/14
!
interface GigabitEthernet1/0/15
!
interface GigabitEthernet1/0/16
!
interface GigabitEthernet1/0/17
!
interface GigabitEthernet1/0/18
!
interface GigabitEthernet1/0/19
!
interface GigabitEthernet1/0/20
!
interface GigabitEthernet1/0/21
!
interface GigabitEthernet1/0/22
!
interface GigabitEthernet1/0/23
!
interface GigabitEthernet1/0/24
!
interface GigabitEthernet1/1/1
!
interface GigabitEthernet1/1/2
!
interface GigabitEthernet1/1/3
!
interface GigabitEthernet1/1/4
!
interface Vlan1
no ip address
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
password cisco
login
!
!
!
!
35 changes: 35 additions & 0 deletions deployments/config-init-db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require("fs");
const util = require("util");
const axios = require("axios");

const interfacesJson = JSON.parse(
fs.readFileSync("../src/schemas/interface.json", "utf8")
);
const generalJson = JSON.parse(
fs.readFileSync("../src/schemas/interface.json", "utf8")
);
const vlanJson = JSON.parse(
fs.readFileSync("../src/schemas/interface.json", "utf8")
);


const pushToDB = async () => {
try {
const host = "http://localhost:3000/api/templates";

await axios.post(host, interfacesJson);
console.log("Interfaces configuration has been sent.");

await axios.post(host, generalJson);
console.log("General configuration has been sent.");

await axios.post(host, vlanJson);
console.log("VLAN configuration has been sent.");
} catch (error) {
console.error("Error sending data");
console.error((error as Error).stack);
}
};

pushToDB();

26 changes: 26 additions & 0 deletions deployments/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3.8"
services:
postgres:
container_name: my-postgres
image: postgres
environment:
POSTGRES_USER: <> # Your username
POSTGRES_PASSWORD: <> # Your password
POSTGRES_DB: <> # Your database name
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
pgadmin:
container_name: my-pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: "<YourMail>"
PGADMIN_DEFAULT_PASSWORD: "<YourPassword>"
ports:
- "5050:80"
depends_on:
- postgres

volumes:
pgdata:
13 changes: 13 additions & 0 deletions deployments/init-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Set the connection details
DB_USER=<> # Enter the username
DB_PASSWORD=<> # Enter the password
DB_NAME=<> # Enter the database name
DB_CONTAINER_NAME="my-postgres"

# Copy the init-db.sql script to the container
docker cp init-db.sql $DB_CONTAINER_NAME:/init-db.sql

# Execute the SQL script inside the container
docker exec -it $DB_CONTAINER_NAME bash -c "PGPASSWORD=$DB_PASSWORD psql -U $DB_USER -d $DB_NAME -a -f /init-db.sql"
25 changes: 25 additions & 0 deletions deployments/init-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE templates (
template_id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
content JSONB NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
user_id INT REFERENCES users(user_id) ON DELETE CASCADE
);

CREATE TABLE saved_configurations (
config_id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(user_id) ON DELETE CASCADE,
template_id INT REFERENCES templates(template_id) ON DELETE SET NULL,
custom_content TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
26 changes: 26 additions & 0 deletions node_modules/@colors/colors/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4859dbf

Please sign in to comment.