Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quassel-status-checker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Janne Mareike Koschinski
quassel-status-checker
Commits
9eaab22b
Verified
Commit
9eaab22b
authored
6 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Implemented first demo of tool for connection to quassel cores
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#431
failed
6 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+5
-0
5 additions, 0 deletions
.gitignore
main.go
+141
-0
141 additions, 0 deletions
main.go
with
146 additions
and
0 deletions
.gitignore
0 → 100644
+
5
−
0
View file @
9eaab22b
*.iml
/.idea/*
!/.idea/copyright/
.DS_Store
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.go
0 → 100644
+
141
−
0
View file @
9eaab22b
package
main
import
(
"bufio"
"crypto/tls"
"encoding/binary"
"fmt"
"net"
)
const
PROTOCOL_MAGIC
uint32
=
0x42b33f00
const
PROTOCOL_FEATURE_TLS
uint8
=
0x01
const
PROTOCOL_FEATURE_COMPRESSION
uint8
=
0x02
const
PROTOCOL_LEGACY
uint32
=
0x01
const
PROTOCOL_DATASTREAM
uint32
=
0x02
type
connection
struct
{
hostname
string
socket
net
.
Conn
tlsSocket
*
tls
.
Conn
readWriter
*
bufio
.
ReadWriter
buffer
[]
byte
}
func
makeConnection
(
address
string
,
port
int
)
connection
{
socket
,
err
:=
net
.
Dial
(
"tcp"
,
fmt
.
Sprintf
(
"%s:%d"
,
address
,
port
))
if
err
!=
nil
{
panic
(
err
.
Error
())
}
return
connection
{
hostname
:
address
,
socket
:
socket
,
readWriter
:
bufio
.
NewReadWriter
(
bufio
.
NewReader
(
socket
),
bufio
.
NewWriter
(
socket
),
),
buffer
:
make
([]
byte
,
4
),
}
}
func
(
c
*
connection
)
write
(
data
uint32
)
{
binary
.
BigEndian
.
PutUint32
(
c
.
buffer
,
data
)
_
,
err
:=
c
.
readWriter
.
Write
(
c
.
buffer
)
if
err
!=
nil
{
panic
(
err
.
Error
())
}
}
func
(
c
*
connection
)
read
(
len
int
)
[]
byte
{
buffer
:=
make
([]
byte
,
len
)
_
,
err
:=
c
.
readWriter
.
Read
(
buffer
)
if
err
!=
nil
{
panic
(
err
.
Error
())
}
return
buffer
}
func
(
c
*
connection
)
flush
()
{
err
:=
c
.
readWriter
.
Flush
()
if
err
!=
nil
{
panic
(
err
.
Error
())
}
}
func
(
c
*
connection
)
withTLS
(
verify
bool
)
{
config
:=
&
tls
.
Config
{
ServerName
:
c
.
hostname
,
InsecureSkipVerify
:
!
verify
,
}
c
.
tlsSocket
=
tls
.
Client
(
c
.
socket
,
config
)
c
.
readWriter
=
bufio
.
NewReadWriter
(
bufio
.
NewReader
(
c
.
tlsSocket
),
bufio
.
NewWriter
(
c
.
tlsSocket
),
)
err
:=
c
.
tlsSocket
.
Handshake
()
if
err
!=
nil
{
panic
(
err
.
Error
())
}
}
func
(
c
*
connection
)
tlsState
()
*
tls
.
ConnectionState
{
if
c
.
tlsSocket
!=
nil
{
state
:=
c
.
tlsSocket
.
ConnectionState
()
return
&
state
}
else
{
return
nil
}
}
func
(
c
*
connection
)
close
()
{
_
=
c
.
readWriter
.
Flush
()
_
=
c
.
tlsSocket
.
Close
()
_
=
c
.
socket
.
Close
()
}
type
protocolInfo
struct
{
flagTLS
bool
flagCompression
bool
data
uint16
version
uint8
}
func
parseProtocolInfo
(
data
[]
byte
)
protocolInfo
{
rawFeatures
:=
data
[
0
]
rawData
:=
data
[
1
:
3
]
rawVersion
:=
data
[
3
]
return
protocolInfo
{
rawFeatures
&
PROTOCOL_FEATURE_TLS
!=
0
,
rawFeatures
&
PROTOCOL_FEATURE_COMPRESSION
!=
0
,
binary
.
BigEndian
.
Uint16
(
rawData
),
rawVersion
,
}
}
func
main
()
{
conn
:=
makeConnection
(
"kuschku.de"
,
4242
)
conn
.
write
(
PROTOCOL_MAGIC
|
uint32
(
PROTOCOL_FEATURE_TLS
))
supportedProtocols
:=
[]
uint32
{
PROTOCOL_DATASTREAM
,
}
for
_
,
protocol
:=
range
supportedProtocols
{
conn
.
write
(
protocol
)
}
conn
.
write
(
1
<<
31
)
conn
.
flush
()
protocolInfo
:=
parseProtocolInfo
(
conn
.
read
(
4
))
println
(
"Read Protocol Info"
)
if
protocolInfo
.
flagTLS
{
conn
.
withTLS
(
false
)
}
if
state
:=
conn
.
tlsState
();
state
!=
nil
{
for
_
,
cert
:=
range
state
.
PeerCertificates
{
println
(
cert
.
NotAfter
.
String
())
}
}
conn
.
close
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment