github.com/iDigitalFlame/xmt@v0.5.4/com/pipe/pipe.go (about) 1 // Copyright (C) 2020 - 2023 iDigitalFlame 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <https://www.gnu.org/licenses/>. 15 // 16 17 // Package pipe contains a cross-device compatable Pipes/NamedPipes connection 18 // interface. This package differs from the standard library as it allows for 19 // setting permissions on the Pipes without any OS-specific functions. 20 package pipe 21 22 import ( 23 "context" 24 "net" 25 "time" 26 ) 27 28 // Pipe is the default Connector with the default timeout of 15 seconds. 29 const Pipe = Piper(time.Second * 15) 30 31 // Piper is a Connector that can be used with the 'c2' package to make Pipe 32 // connections for C2. 33 type Piper time.Duration 34 35 // Connect fulfills the Connector interface. 36 func (p Piper) Connect(x context.Context, a string) (net.Conn, error) { 37 return DialContext(x, Format(a)) 38 } 39 40 // Listen fulfills the Connector interface. 41 func (Piper) Listen(x context.Context, a string) (net.Listener, error) { 42 return ListenPermsContext(x, Format(a), PermEveryone) 43 }