forked from moul/sshportal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* * When a new channel is opened we got stuck in the select loop in bastionsession.go, and we couldn't open a new channel. The fix is easy it calls the bastionsession.ChannelHandler in a goroutine, at the cost of some error management. I think this is ok because we can allow a channel to fail on his own. This seems to be * This add the tunnel feature, which use a new concurrent channel. * This add some pcap logging for tunnel. For now it is logged only one way, and the logged ip packet seems buggy. * Add logtunnuel as a package. The logfile format is a tweaked version of ttyrec format file as it will be easy to review the use of human readable tunnel... To get the ChannelHandler work as a go routine I had to deactivate lint errcheck for logcahnnel. I think this could be a problem. What is your thoughts about this ?
- Loading branch information
Manuel Sabban
authored
Jan 18, 2018
1 parent
7c4aab3
commit 2c3de75
Showing
3 changed files
with
156 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package logtunnel | ||
|
||
import ( | ||
"encoding/binary" | ||
"io" | ||
"syscall" | ||
"time" | ||
|
||
"golang.org/x/crypto/ssh" | ||
) | ||
|
||
type logTunnel struct { | ||
host string | ||
channel ssh.Channel | ||
writer io.WriteCloser | ||
} | ||
|
||
type ForwardData struct { | ||
DestinationHost string | ||
DestinationPort uint32 | ||
SourceHost string | ||
SourcePort uint32 | ||
} | ||
|
||
func writeHeader(fd io.Writer, length int) { | ||
t := time.Now() | ||
|
||
tv := syscall.NsecToTimeval(t.UnixNano()) | ||
|
||
binary.Write(fd, binary.LittleEndian, int32(tv.Sec)) | ||
binary.Write(fd, binary.LittleEndian, int32(tv.Usec)) | ||
binary.Write(fd, binary.LittleEndian, int32(length)) | ||
} | ||
|
||
func New(channel ssh.Channel, writer io.WriteCloser, host string) *logTunnel { | ||
return &logTunnel{ | ||
host: host, | ||
channel: channel, | ||
writer: writer, | ||
} | ||
} | ||
|
||
func (l *logTunnel) Read(data []byte) (int, error) { | ||
return l.Read(data) | ||
} | ||
|
||
func (l *logTunnel) Write(data []byte) (int, error) { | ||
writeHeader(l.writer, len(data) + len(l.host + ": ")) | ||
l.writer.Write([]byte(l.host + ": ")) | ||
l.writer.Write(data) | ||
|
||
return l.channel.Write(data) | ||
} | ||
|
||
func (l *logTunnel) Close() error { | ||
l.writer.Close() | ||
|
||
return l.channel.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters