Skip to content

Commit

Permalink
Added get-all-printer-attrs to the [logging] section
Browse files Browse the repository at this point in the history
By default, during initialization ipp-usb requests only those IPP printer
attributes that it needs by itself. If this option is enabled, it will
request **all** printer attributes.

Normally, it should affect only logging (as returned attributes
are written to log). However, some enterprise-quality HP printers are so
slow in returning all attributes, so it can cause initializatio
timeouts, so by default this option is disabled.

See also #32 for some details on initialization timeout when all
printer attributes are requested.
  • Loading branch information
alexpevzner committed Nov 9, 2023
1 parent d848dd3 commit df8aa9c
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 41 deletions.
54 changes: 29 additions & 25 deletions conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,37 @@ const (

// Configuration represents a program configuration
type Configuration struct {
HTTPMinPort int // Starting port number for HTTP to bind to
HTTPMaxPort int // Ending port number for HTTP to bind to
DNSSdEnable bool // Enable DNS-SD advertising
LoopbackOnly bool // Use only loopback interface
IPV6Enable bool // Enable IPv6 advertising
ConfAuthUID []*AuthUIDRule // [auth uid], parsed
LogDevice LogLevel // Per-device LogLevel mask
LogMain LogLevel // Main log LogLevel mask
LogConsole LogLevel // Console LogLevel mask
LogMaxFileSize int64 // Maximum log file size
LogMaxBackupFiles uint // Count of files preserved during rotation
ColorConsole bool // Enable ANSI colors on console
Quirks QuirksSet // Device quirks
HTTPMinPort int // Starting port number for HTTP to bind to
HTTPMaxPort int // Ending port number for HTTP to bind to
DNSSdEnable bool // Enable DNS-SD advertising
LoopbackOnly bool // Use only loopback interface
IPV6Enable bool // Enable IPv6 advertising
ConfAuthUID []*AuthUIDRule // [auth uid], parsed
LogDevice LogLevel // Per-device LogLevel mask
LogMain LogLevel // Main log LogLevel mask
LogConsole LogLevel // Console LogLevel mask
LogMaxFileSize int64 // Maximum log file size
LogMaxBackupFiles uint // Count of files preserved during rotation
LogAllPrinterAttrs bool // Get *all* printer attrs, for logging
ColorConsole bool // Enable ANSI colors on console
Quirks QuirksSet // Device quirks
}

// Conf contains a global instance of program configuration
var Conf = Configuration{
HTTPMinPort: 60000,
HTTPMaxPort: 65535,
DNSSdEnable: true,
LoopbackOnly: true,
IPV6Enable: true,
ConfAuthUID: nil,
LogDevice: LogDebug,
LogMain: LogDebug,
LogConsole: LogDebug,
LogMaxFileSize: 256 * 1024,
LogMaxBackupFiles: 5,
ColorConsole: true,
HTTPMinPort: 60000,
HTTPMaxPort: 65535,
DNSSdEnable: true,
LoopbackOnly: true,
IPV6Enable: true,
ConfAuthUID: nil,
LogDevice: LogDebug,
LogMain: LogDebug,
LogConsole: LogDebug,
LogMaxFileSize: 256 * 1024,
LogMaxBackupFiles: 5,
LogAllPrinterAttrs: false,
ColorConsole: true,
}

// ConfLoad loads the program configuration
Expand Down Expand Up @@ -147,6 +149,8 @@ func confLoadInternal(path string) error {
err = rec.LoadSize(&Conf.LogMaxFileSize)
case confMatchName(rec.Key, "max-backup-files"):
err = rec.LoadUint(&Conf.LogMaxBackupFiles)
case confMatchName(rec.Key, "get-all-printer-attrs"):
err = rec.LoadBool(&Conf.LogAllPrinterAttrs)
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion ipp-usb.8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "IPP\-USB" "8" "July 2023" "" "ipp-usb.8"
.TH "IPP\-USB" "8" "November 2023" "" "ipp-usb.8"
.SH "NAME"
\fBipp\-usb\fR \- Daemon for IPP over USB printer support
.SH "DESCRIPTION"
Expand Down Expand Up @@ -203,6 +203,17 @@ Logging parameters are all in the \fB[logging]\fR section:

# Enable or disable ANSI colors on console
console\-color = enable # enable | disable

# ipp\-usb queries IPP printer attributes at the initialization time
# for its own purposes and writes received attributes to the log\.
# By default, only necessary attributes are requested from device\.
#
# If this parameter is set to true, all printer attributes will
# be requested\. Normally, it only affects the logging\. However,
# some enterprise\-level HP printers returns such huge amount of
# data and do it so slowly, so it can cause initialization timeout\.
# This is why this feature is not enabled by default
get\-all\-printer\-attrs = false # false | true
.fi
.IP "" 0
.SS "Quirks"
Expand Down
11 changes: 11 additions & 0 deletions ipp-usb.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ Logging parameters are all in the `[logging]` section:
# Enable or disable ANSI colors on console
console-color = enable # enable | disable

# ipp-usb queries IPP printer attributes at the initialization time
# for its own purposes and writes received attributes to the log.
# By default, only necessary attributes are requested from device.
#
# If this parameter is set to true, all printer attributes will
# be requested. Normally, it only affects the logging. However,
# some enterprise-level HP printers returns such huge amount of
# data and do it so slowly, so it can cause initialization timeout.
# This is why this feature is not enabled by default
get-all-printer-attrs = false # false | true

### Quirks

Some devices, due to their firmware bugs, require special handling,
Expand Down
11 changes: 11 additions & 0 deletions ipp-usb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,15 @@
# Enable or disable ANSI colors on console
console-color = enable # enable | disable

# ipp-usb queries IPP printer attributes at the initialization time
# for its own purposes and writes received attributes to the log.
# By default, only necessary attributes are requested from device.
#
# If this parameter is set to true, all printer attributes will
# be requested. Normally, it only affects the logging. However,
# some enterprise-level HP printers returns such huge amount of
# data and do it so slowly, so it can cause initialization timeout.
# This is why this feature is not enabled by default
get-all-printer-attrs = false # false | true

# vim:ts=8:sw=2:et
36 changes: 21 additions & 15 deletions ipp.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,27 @@ func ippGetPrinterAttributes(log *LogMessage, c *http.Client, uri string) (
goipp.TagURI, goipp.String(uri)))

rq := goipp.Attribute{Name: "requested-attributes"}
rq.Values.Add(goipp.TagKeyword, goipp.String("color-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("document-format-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("media-size-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("mopria-certified"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-device-id"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-dns-sd-name"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-icons"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-info"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-kind"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-location"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-make-and-model"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-more-info"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-uuid"))
rq.Values.Add(goipp.TagKeyword, goipp.String("sides-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("urf-supported"))

if Conf.LogAllPrinterAttrs {
rq.Values.Add(goipp.TagKeyword, goipp.String("all"))
} else {
rq.Values.Add(goipp.TagKeyword, goipp.String("color-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("document-format-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("media-size-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("mopria-certified"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-device-id"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-dns-sd-name"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-icons"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-info"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-kind"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-location"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-make-and-model"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-more-info"))
rq.Values.Add(goipp.TagKeyword, goipp.String("printer-uuid"))
rq.Values.Add(goipp.TagKeyword, goipp.String("sides-supported"))
rq.Values.Add(goipp.TagKeyword, goipp.String("urf-supported"))
}

msg.Operation.Add(rq)

log.Add(LogTraceIPP, '>', "IPP request:").
Expand Down

0 comments on commit df8aa9c

Please sign in to comment.