// ucspi/cmd/proxy -- UCSPI TCP proxy // Copyright (C) 2021-2024 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package main import ( "flag" "fmt" "io" "log" "os" ) func main() { flag.Usage = func() { fmt.Fprintln(os.Stderr, "Usage: UCSPIserver [address] UCSPIclient [address] ucspi-proxy") } flag.Parse() log.SetFlags(log.Lshortfile) r := os.NewFile(6, "R") if r == nil { log.Fatalln("no 6 file descriptor") } w := os.NewFile(7, "W") if w == nil { log.Fatalln("no 7 file descriptor") } worker := make(chan struct{}) var err error go func() { _, err = io.Copy(w, os.Stdin) w.Close() close(worker) }() go func() { io.Copy(os.Stdout, r) }() <-worker if err != nil { log.Fatalln(err) } }