package lpd import ( osm "git.loafle.net/overflow/service_matcher-go" ) type LPDMatcher struct { osm.Matchers } func (m *LPDMatcher) Key() string { return "LPD" } func (m *LPDMatcher) Type() string { return "NETWORK" } func (m *LPDMatcher) Vendor(matchCtx *osm.MatchCtx) string { return "UNKNOWN" } func (m *LPDMatcher) Version(matchCtx *osm.MatchCtx) string { return "UNKNOWN" } func (m *LPDMatcher) OsType(matchCtx *osm.MatchCtx) string { return "UNKNOWN" } func (m *LPDMatcher) OsVersion(matchCtx *osm.MatchCtx) string { return "UNKNOWN" } func (m *LPDMatcher) Name(matchCtx *osm.MatchCtx) string { return "LPD (Printer)" } func (m *LPDMatcher) IsPrePacket() bool { return false } func (m *LPDMatcher) HasResponse(matchCtx *osm.MatchCtx, index int) bool { return true } func (m *LPDMatcher) IsError(matchCtx *osm.MatchCtx, index int, packet *osm.Packet) bool { return false } func (m *LPDMatcher) Match(matchCtx *osm.MatchCtx, index int, packet *osm.Packet) error { if packet == nil || !packet.Valid() { return osm.NoPacketReceivedError() } if packet.Len != 1 { return osm.NotMatchedError() } return nil } func NewMatcher() osm.Matcher { m := &LPDMatcher{} reqStr := "GET / HTTP/1.1\r\n\r\n" rbyte := make([]byte, len(reqStr)) copy(rbyte[:], reqStr) m.AddPacket(osm.NewPacket(rbyte, len(reqStr))) return m }