Compare commits
No commits in common. "ccb1a93aa5b547e87f855f9bd9a0452db7193e57" and "a1defca77275373188bb74931abc560830fc26af" have entirely different histories.
ccb1a93aa5
...
a1defca772
4
app.go
4
app.go
|
@ -1,7 +1,6 @@
|
||||||
package npc
|
package npc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fyne.io/fyne/v2"
|
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
|
@ -10,7 +9,6 @@ import (
|
||||||
func Appmain() {
|
func Appmain() {
|
||||||
a := app.New()
|
a := app.New()
|
||||||
w := a.NewWindow("Hello")
|
w := a.NewWindow("Hello")
|
||||||
w.Resize(fyne.NewSize(800, 600))
|
|
||||||
|
|
||||||
hello := widget.NewLabel("Hello Fyne!")
|
hello := widget.NewLabel("Hello Fyne!")
|
||||||
w.SetContent(container.NewBorder(
|
w.SetContent(container.NewBorder(
|
||||||
|
@ -18,7 +16,7 @@ func Appmain() {
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
container.NewVScroll(GetProtocolEditor().Representation),
|
container.NewVScroll(GetFieldEditor().Representation),
|
||||||
// widget.NewButton("Hi!", func() {
|
// widget.NewButton("Hi!", func() {
|
||||||
// hello.SetText("Welcome :)")
|
// hello.SetText("Welcome :)")
|
||||||
// }),
|
// }),
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
package npc
|
|
||||||
|
|
||||||
func NewDataModel(name string) *DataModel {
|
|
||||||
return &DataModel{
|
|
||||||
Name: name,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) AddProtocol(name string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) RemoveProtocolByName(name string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) RemoveProtocolElement(id uint) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) NewProtocol(name string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) SaveNewProtocol(editorContent ProtocolEditor) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) GetPackageEditor() *PackageEditor {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) SwitchToProtocolEditor() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) SyncPackageEditor(pkgedt *PackageEditor) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) GetPackageBytes() []byte {
|
|
||||||
|
|
||||||
return []byte{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) FromSaved(path string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dm *DataModel) SaveAsPcap(path string) {
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package npc
|
||||||
|
|
||||||
|
type Field struct {
|
||||||
|
Name string
|
||||||
|
Desc string
|
||||||
|
Regex string
|
||||||
|
ByteSize uint
|
||||||
|
BitSize uint
|
||||||
|
}
|
||||||
|
|
||||||
|
type FieldValue struct {
|
||||||
|
FieldRef *Field
|
||||||
|
Value string
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ var fieldAdder *widget.Button
|
||||||
func GetAdder() *widget.Button {
|
func GetAdder() *widget.Button {
|
||||||
if fieldAdder == nil {
|
if fieldAdder == nil {
|
||||||
fieldAdder = widget.NewButton("Add Field", func() {
|
fieldAdder = widget.NewButton("Add Field", func() {
|
||||||
protocolEditor.AddFieldCreator(CreateFieldCreator())
|
fieldEditor.AddFieldCreator(CreateFieldCreator())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return fieldAdder
|
return fieldAdder
|
||||||
|
|
|
@ -12,18 +12,14 @@ type FieldCreator struct {
|
||||||
NameValue *widget.Entry
|
NameValue *widget.Entry
|
||||||
DescValue *widget.Entry
|
DescValue *widget.Entry
|
||||||
RegExValue *widget.Entry
|
RegExValue *widget.Entry
|
||||||
SizeLabel *widget.Label
|
ByteSizeValue *widget.Entry
|
||||||
SizeValue *widget.Entry
|
BitSizeValue *widget.Entry
|
||||||
SizeInBits bool
|
|
||||||
// to be filled with needed things
|
// to be filled with needed things
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateFieldCreator() *FieldCreator {
|
func CreateFieldCreator() *FieldCreator {
|
||||||
fc := &FieldCreator{}
|
fc := &FieldCreator{}
|
||||||
fc.Representation = container.New(layout.NewFormLayout())
|
fc.Representation = container.New(layout.NewVBoxLayout())
|
||||||
|
|
||||||
fc.Representation.Add(widget.NewLabel(""))
|
|
||||||
fc.Representation.Add(widget.NewLabel("Field Values"))
|
|
||||||
|
|
||||||
fc.Representation.Add(widget.NewLabel("Name"))
|
fc.Representation.Add(widget.NewLabel("Name"))
|
||||||
fc.NameValue = widget.NewEntry()
|
fc.NameValue = widget.NewEntry()
|
||||||
|
@ -31,26 +27,16 @@ func CreateFieldCreator() *FieldCreator {
|
||||||
|
|
||||||
fc.Representation.Add(widget.NewLabel("Description"))
|
fc.Representation.Add(widget.NewLabel("Description"))
|
||||||
fc.DescValue = widget.NewEntry()
|
fc.DescValue = widget.NewEntry()
|
||||||
fc.DescValue.MultiLine = true
|
|
||||||
fc.DescValue.SetMinRowsVisible(3)
|
|
||||||
fc.Representation.Add(fc.DescValue)
|
fc.Representation.Add(fc.DescValue)
|
||||||
|
|
||||||
fc.Representation.Add(widget.NewLabel("RegEx"))
|
fc.Representation.Add(widget.NewLabel("RegEx"))
|
||||||
fc.RegExValue = widget.NewEntry()
|
fc.RegExValue = widget.NewEntry()
|
||||||
fc.Representation.Add(fc.RegExValue)
|
fc.Representation.Add(fc.RegExValue)
|
||||||
|
|
||||||
fc.SizeLabel = widget.NewLabel("Bytes")
|
fc.Representation.Add(widget.NewLabel("ByteSize"))
|
||||||
|
fc.ByteSizeValue = widget.NewEntry()
|
||||||
toggleBtn := widget.NewButton("T", func() {
|
fc.Representation.Add(fc.ByteSizeValue)
|
||||||
if fc.SizeInBits {
|
// add that later
|
||||||
fc.SizeLabel.SetText("Bytes")
|
fc.BitSizeValue = widget.NewEntry()
|
||||||
} else {
|
|
||||||
fc.SizeLabel.SetText("Bits")
|
|
||||||
}
|
|
||||||
fc.SizeInBits = !fc.SizeInBits
|
|
||||||
})
|
|
||||||
fc.Representation.Add(container.NewHBox(toggleBtn, fc.SizeLabel))
|
|
||||||
fc.SizeValue = widget.NewEntry()
|
|
||||||
fc.Representation.Add(fc.SizeValue)
|
|
||||||
return fc
|
return fc
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package npc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FieldEditor struct {
|
||||||
|
Representation *fyne.Container
|
||||||
|
Creators []*FieldCreator
|
||||||
|
}
|
||||||
|
|
||||||
|
var fieldEditor *FieldEditor
|
||||||
|
|
||||||
|
func GetFieldEditor() *FieldEditor {
|
||||||
|
if fieldEditor == nil {
|
||||||
|
container := NewFlowLayout()
|
||||||
|
fieldEditor = &FieldEditor{container, []*FieldCreator{}}
|
||||||
|
container.Add(GetAdder())
|
||||||
|
}
|
||||||
|
return fieldEditor
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *FieldEditor) AddFieldCreator(fieldCreator *FieldCreator) {
|
||||||
|
ed.Creators = append(fieldEditor.Creators, fieldCreator)
|
||||||
|
ed.Redraw()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *FieldEditor) Redraw() {
|
||||||
|
ed.Representation.RemoveAll()
|
||||||
|
for _, v := range ed.Creators {
|
||||||
|
ed.Representation.Add(v.Representation)
|
||||||
|
fmt.Printf("Minsize: %f, %f", v.Representation.MinSize().Height, v.Representation.MinSize().Width)
|
||||||
|
}
|
||||||
|
ed.Representation.Add(GetAdder())
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package npc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/theme"
|
"fyne.io/fyne/v2/theme"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,9 +11,9 @@ type FlowLayout struct {
|
||||||
LastMinDimensions fyne.Size
|
LastMinDimensions fyne.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFlowLayout(o ...fyne.CanvasObject) fyne.Layout {
|
func NewFlowLayout(o ...fyne.CanvasObject) *fyne.Container {
|
||||||
f := &FlowLayout{}
|
f := &FlowLayout{}
|
||||||
return f
|
return container.New(f, o...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinSize is a kind of boogie function for the flow layout.
|
// MinSize is a kind of boogie function for the flow layout.
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -2,7 +2,10 @@ module gitea.mmo.to/NetworkPacketComposer/npc
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require fyne.io/fyne/v2 v2.2.4
|
require (
|
||||||
|
fyne.io/fyne/v2 v2.2.4
|
||||||
|
github.com/magiconair/properties v1.8.5
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
|
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
|
||||||
|
@ -18,7 +21,6 @@ require (
|
||||||
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff // indirect
|
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff // indirect
|
||||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||||
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
|
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564 // indirect
|
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564 // indirect
|
||||||
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 // indirect
|
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9 // indirect
|
||||||
|
|
3
go.sum
3
go.sum
|
@ -207,9 +207,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
|
||||||
github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc=
|
github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc=
|
||||||
|
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
|
||||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package npc
|
|
||||||
|
|
||||||
import "fyne.io/fyne/v2"
|
|
||||||
|
|
||||||
type PackageEditor struct {
|
|
||||||
Representation *fyne.Container
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package npc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fyne.io/fyne/v2"
|
|
||||||
"fyne.io/fyne/v2/container"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ProtocolEditor struct {
|
|
||||||
Representation *fyne.Container
|
|
||||||
Creators []*FieldCreator
|
|
||||||
}
|
|
||||||
|
|
||||||
var protocolEditor *ProtocolEditor
|
|
||||||
|
|
||||||
func GetProtocolEditor() *ProtocolEditor {
|
|
||||||
if protocolEditor == nil {
|
|
||||||
container := container.NewGridWrap(fyne.NewSize(300, 300))
|
|
||||||
protocolEditor = &ProtocolEditor{container, []*FieldCreator{}}
|
|
||||||
container.Add(GetAdder())
|
|
||||||
}
|
|
||||||
return protocolEditor
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ed *ProtocolEditor) AddFieldCreator(fieldCreator *FieldCreator) {
|
|
||||||
ed.Creators = append(protocolEditor.Creators, fieldCreator)
|
|
||||||
ed.Redraw()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ed *ProtocolEditor) Redraw() {
|
|
||||||
ed.Representation.RemoveAll()
|
|
||||||
for _, v := range ed.Creators {
|
|
||||||
ed.Representation.Add(v.Representation)
|
|
||||||
}
|
|
||||||
ed.Representation.Add(GetAdder())
|
|
||||||
}
|
|
46
structure.go
46
structure.go
|
@ -1,46 +0,0 @@
|
||||||
package npc
|
|
||||||
|
|
||||||
type Field struct {
|
|
||||||
Name string // Name of the Field
|
|
||||||
Desc string // Lengthy description
|
|
||||||
Regex string // Regex to recognize values
|
|
||||||
Size uint // Size in bits!
|
|
||||||
SubFields []Field // Possible sub-fields
|
|
||||||
Optional bool // Is this field required?
|
|
||||||
Payload bool // Is this field the payload or next protocol level?
|
|
||||||
PredefinedValues []PredefinedFieldValue // Collection of predefined field values
|
|
||||||
}
|
|
||||||
|
|
||||||
type PredefinedFieldValue struct {
|
|
||||||
Desc string
|
|
||||||
FieldValues []FieldValue
|
|
||||||
}
|
|
||||||
|
|
||||||
type FieldValue struct {
|
|
||||||
FieldRef *Field
|
|
||||||
Value string
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProtocolStructure struct {
|
|
||||||
Metadata DOPMetadata
|
|
||||||
Structure []Field
|
|
||||||
}
|
|
||||||
|
|
||||||
type DOPMetadata struct {
|
|
||||||
DOPVersion string
|
|
||||||
Name string
|
|
||||||
Version string
|
|
||||||
TCPIPLayer uint
|
|
||||||
OSILayer uint
|
|
||||||
ExtensionTo string
|
|
||||||
Description string
|
|
||||||
RequiredJSFunctions []string
|
|
||||||
LowerLayerIdentification map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
type DataModel struct {
|
|
||||||
Name string // User defined name of his current work (filename later)
|
|
||||||
Protocols []ProtocolStructure // List of protocols in order of the stack
|
|
||||||
Data []FieldValue // Data of the fields of all protocols
|
|
||||||
ProtocolCreation bool
|
|
||||||
}
|
|
Loading…
Reference in New Issue