package lpd import ( osm "git.loafle.net/overflow/service_matcher-go" ) type LPDMatcher struct { osm.Matchers meta osm.Metadata } func (l *LPDMatcher) Key() string { return "LPD" } func (l *LPDMatcher) Meta() osm.Metadata { return l.meta } func (l *LPDMatcher) Name() string { return "LPD (Printer)" } func (l *LPDMatcher) IsPrePacket() bool { return false } func (l *LPDMatcher) HasResponse(index int) bool { return true } func (l *LPDMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet) bool { return false } func (l *LPDMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error { if packet == nil || packet.Buffer == nil || packet.Len == 0 { 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 }