Coder Social home page Coder Social logo

if-unismuh / hands-on-network-programming-with-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ec-council-learning/hands-on-network-programming-with-go

0.0 0.0 0.0 2.53 MB

Hands-on Network Programming with Go, by EC-Council

License: MIT License

Shell 0.18% Go 99.82%

hands-on-network-programming-with-go's Introduction

Hands-on-Network-Programming-with-Go

Hands-on Network Programming with Go, by EC-Council

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

SSH_USER

SSH_PASSWORD

POSTGRES_USER

POSTGRES_PASSWORD

DSN

For example:

export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export DSN=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/device_inventory

Run Locally

Clone the project

  git clone https://github.com/codered-by-ec-council/Hands-on-Network-Programming-with-Go.git

Go to the project directory

  cd Hands-on-Network-Programming-with-Go

Install dependencies

go mod download

Spin up the postgres container

# create the volume initially
docker-compose up

Start the web server

go run cmd/web/*.go

Usage/Examples

Fire up the Miminal server

cd cmd/server
go build -o custom-server
sudo -E ./custom-server

Run Command via CLI

package main

import (
	"flag"
	"fmt"
	"log"

	"github.com/codered-by-ec-council/Hands-on-Network-Programming-with-Go/pkg/devcon"
)

func main() {
	target := flag.String("target", "127.0.0.1", "target against which to run a command")
	cmd := flag.String("cmd", "", "command to run against target device")
	flag.Parse()
	client := devcon.NewClient(*target)
	output, err := client.Run(*cmd)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(output)
}

Run a Change with cmdrunner

package main

import (
	"log"

	"github.com/codered-by-ec-council/Hands-on-Network-Programming-with-Go/pkg/cmdrunner"
)

func main() {
	isisAdj := &cmdrunner.ISISAdjacencyRpcReply{Target: "labsrx", ExpectedNeighbor: "lab_srx100"}
	sr := &cmdrunner.SpecificRouteRpcReply{Target: "labsrx", ExpectedNextHop: "192.168.0.1"}
	cmds := []cmdrunner.Runner{isisAdj, sr}
	if err := cmdrunner.Stepper(cmds); err != nil {
		log.Println(err)
	}
}

hands-on-network-programming-with-go's People

Contributors

montybeatnik avatar siddheshk-eccouncil avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.