mirror of
https://github.com/tuxdotrs/trok.git
synced 2026-09-19 23:19:03 +05:30
Compare commits
5 Commits
e451f17df0
...
6c13858d46
| Author | SHA1 | Date | |
|---|---|---|---|
|
6c13858d46
|
|||
|
ad3792139d
|
|||
|
c1ba1e55d0
|
|||
|
a616409ee0
|
|||
|
3cceda5835
|
@@ -90,7 +90,7 @@ trok = {
|
||||
inputs.trok.nixosModules.default
|
||||
];
|
||||
|
||||
tux.services.trok = {
|
||||
services.trok = {
|
||||
enable = true;
|
||||
host = "0.0.0.0";
|
||||
port = 1337;
|
||||
|
||||
46
flake.nix
46
flake.nix
@@ -2,28 +2,32 @@
|
||||
description = "Simple tunneler in Go that exposes local ports to the internet";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
}: let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
}:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
forAllSystems = function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
|
||||
in {
|
||||
packages = forAllSystems (pkgs: rec {
|
||||
default = trok;
|
||||
trok = pkgs.callPackage ./default.nix {};
|
||||
});
|
||||
forAllSystems =
|
||||
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (pkgs: rec {
|
||||
default = trok;
|
||||
trok = pkgs.callPackage ./package.nix { };
|
||||
});
|
||||
|
||||
nixosModules.default = ./module.nix;
|
||||
nixosModules.default = ./module.nix;
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.callPackage ./shell.nix {};
|
||||
});
|
||||
};
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.callPackage ./shell.nix { };
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type Trok struct {
|
||||
|
||||
func (t *Trok) Init(addr string) error {
|
||||
t.publicConns = make(map[string]Conn)
|
||||
t.webServer = NewTrokWeb(":443")
|
||||
t.webServer = NewTrokWeb(":1338")
|
||||
err := t.controlServer.Init(addr, "Controller")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/tuxdotrs/trok/internal/web"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
)
|
||||
|
||||
type TrokWeb struct {
|
||||
@@ -36,29 +34,7 @@ func (t *TrokWeb) Start() {
|
||||
Browse: true,
|
||||
}))
|
||||
|
||||
cfg := t.GetTLSCert()
|
||||
|
||||
ln, err := tls.Listen("tcp", t.addr, cfg)
|
||||
if err != nil {
|
||||
log.Panic().Msgf("unable to start trok webserver: %v", err)
|
||||
}
|
||||
|
||||
t.app.Listener(ln)
|
||||
}
|
||||
|
||||
func (t *TrokWeb) GetTLSCert() *tls.Config {
|
||||
m := &autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist("trok.cloud"),
|
||||
Cache: autocert.DirCache("./certs"),
|
||||
}
|
||||
|
||||
return &tls.Config{
|
||||
GetCertificate: m.GetCertificate,
|
||||
NextProtos: []string{
|
||||
"http/1.1", "acme-tls/1",
|
||||
},
|
||||
}
|
||||
log.Panic().Err(t.app.Listen(t.addr)).Msg("unable to start trok webserver")
|
||||
}
|
||||
|
||||
func (t *TrokWeb) Stop() {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.tux.services.trok;
|
||||
cfg = config.services.trok;
|
||||
in {
|
||||
options.tux.services.trok = {
|
||||
options.services.trok = {
|
||||
enable = mkEnableOption "Enable trok";
|
||||
|
||||
host = mkOption {
|
||||
|
||||
@@ -11,7 +11,7 @@ buildGoModule {
|
||||
|
||||
meta = {
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [tuxdotrs];
|
||||
maintainers = with lib.maintainers; [ tuxdotrs ];
|
||||
mainProgram = "trok";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user