Quick Start
Introduction
In modern systems, building an application is only half the battle. Running it on your machine is very different from running it in a real environment: you still need to deploy it, configure it, and secure it. As a developer, you may not want to become an expert in proxies, VPNs, firewalls, and the underlying infrastructure just to get two services talking.
VeilNet is a library that adds secure connectivity to your applications directly in code. You focus on your app; VeilNet handles the network.
Let's get started
VeilNet currently supports Go. Suuport for Python is coming soon. Add the Conflux dependency to your project:
go get github.com/veil-net/conflux
Think of VeilNet Conflux as a subprocess that runs alongside your main process. It creates a virtual network interface so your application can talk to other applications on the VeilNet overlay.
Step 1: Start the VeilNet Conflux Plugin
Start the VeilNet Conflux Plugin first. It runs as a subprocess alongside your app and sets up the virtual network interface so your application can connect to others on VeilNet.
You need to pass:
- Token — A registration token from your VeilNet management console.
- Tag — A name to identify your application (optional).
- IP — The VeilNet IP address for this application (optional).
Note: Starting the Conflux plugin attaches your process to your VeilNet environment using the provided token.
Warning: The Conflux plugin needs network administrator privileges to create a virtual network interface.
package main
import "github.com/veil-net/conflux/anchor"
func main() {
// Start the VeilNet Conflux Plugin
subprocess, anchor, err := anchor.StartConflux(token string, tag string, ip string, nil, nil)
if err != nil {
return err
}
// ...
}
Step 2: Start your application
Once the Conflux plugin is running, start your application as usual. You don't need to rewrite your app—just run it with the plugin enabled. Below is a simple HTTP server that responds with "Hello World".
package main
import (
"fmt"
"context"
"net/http"
"github.com/veil-net/conflux/anchor"
)
func main() {
// Start the VeilNet Conflux Plugin
subprocess, anchor, err := anchor.StartConflux(token, tag, ip, nil, nil)
if err != nil {
return err
}
// Add taint to the conflux node
_, err = anchor.AddTaint(context.Background(), &pb.AddTaintRequest{
Taint: "test",
})
if err != nil {
return
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World")
})
http.ListenAndServe(fmt.Sprintf("%s:8080", ip), nil)
}
If the server is reachable at 10.128.0.1:8080, a client can call it over VeilNet like this:
package main
import (
"fmt"
"io"
"log"
"net/http"
"github.com/veil-net/conflux/anchor"
)
func main() {
subprocess, _, err := anchor.StartConflux(token, tag, ip, nil, nil)
if err != nil {
log.Fatal(err)
}
defer subprocess.Stop()
// Add taint to the conflux node
_, err = anchor.AddTaint(context.Background(), &pb.AddTaintRequest{
Taint: "test",
})
if err != nil {
return
}
// Call the server over VeilNet (server is at 10.128.0.1:8080)
resp, err := http.Get("http://10.128.0.1:8080/")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body)) // Hello World
}
IP and Tag are optional. If you omit them, Conflux will assign defaults. This is fine for clients that only need to reach a server. For server-side applications, set them if you need a stable, predictable address.
