npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

airprint-proxy

v1.2.0

Published

AirPrint proxy for network printers located outside the network

Downloads

17

Readme

AirPrint Proxy

____ _ ____ ___  ____ _ _  _ ___    ___  ____ ____ _  _ _   _ 
|__| | |__/ |__] |__/ | |\ |  |     |__] |__/ |  |  \/   \_/  
|  | | |  \ |    |  \ | | \|  |     |    |  \ |__| _/\_   |

Build Status npm version

NPM

Advertise AirPrint printers for network printers located outside the subnet using node. GPL-3.0 licensed.

It's Working!

Copyright (C) 2017 Marcus Zhou

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Introduction

This library provides the ability to create a A record which points to an external printer's ip address, and advertise that printer as a AirPrint supported printer. The only parameters really needed to setup is the ip address.

This library can also be used in scenario like the printer is located in another room under a specific subnet that can be reached by ip address but cannot be reached by multicast packets like mdns. By running this proxy on a device located inside the localnet, the phones and computers should be able to discover the printers.

Node: The remote printer needs to support the MIME type image/urf

The library does not provide any kind of translation functions that converts the Apple Raster format to others, which requires the remote printing server to natively support the format.

Requirements & Compatibility

airprint-proxy requires node version greater or equal 8.3.0 to run.

airprint-proxy is compatible with node 10.

Setup

Install as global package:

# For npm users
npm install -g airprint-proxy

# For yarn users
yarn global add airprint-proxy

Install as dependency:

# For npm users
npm install airprint-proxy

# For yarn users
yarn add airprint-proxy

Usage

AirPrint Proxy comes with both Command Line Interface (CLI) and programmable APIs.

Commands

Install AirPrint Proxy as global package to use the command. (See the section above)

Usage: airprint-proxy [...options] <url|ip>

Available options

| Short | Full | Description | Default Value | | ----- | -------------- | ------------------------------------------------------------------------- | -------------------------- | | -p | --port | The port of the printing server that clients will be connect to | 631 | | -n | --name | The name of the printer that will be broadcasts to the local network | "Untitled Bonjour Printer" | | -l | --location | The notes which will be shown as the location of the printer | "" | | -q | --queue | The queue on the printing server which clients will be communicating with | "ipp/print" | | -c | --color | Broadcast this printer as a color printer | false | | -d | --duplex | Broadcast this printer as duplex supported | false | | -m | --mime-types | Specify additional supported MIME types beside 'image/urf'. | | | -o | --txt-record | Add additional txt records. (E.g. -o you=me) | | | -h | --help | Show help message | | | -a | --automatic | Automatically resolve and configure printer from ip address | false |

Examples

# Automatically resolve the printer's name and capabilities from its ip address
airprint-proxy -a 10.35.0.18

# Broadcast a remote printer at 10.35.0.18 (without asking the printer what it can do)
airprint-proxy 10.35.0.18

# Broadcast the same printer with name "Library Color"
airprint-proxy --name "Library Color" 10.35.0.18

# Broadcast the same printer with name "US Commons" and location "Upper School 1st Floor"
airprint-proxy --name "Library Color" --location "Upper School 1st Floor" 10.35.0.18

APIs

The PrinterProxy object is setup to manage all mdns requests, so be sure to instantiate one every time.

//CommonJS style
const APProxy = require("airprint-proxy");
const PrinterProxy = APProxy.PrinterProxy;
const Printer = APProxy.Printer;

//ES6 style
import { PrinterProxy, Printer } from "airprint-proxy";

let proxy = new PrinterProxy();

Use Printer to represent each printer.

//This is the complex way
let printer = new Printer(
    "10.35.0.18",            //IP Address <required>
    "Library Color Printer", //Name <optional>
    631,                     //Port <optional>
    "Media Center",          //Notes, will be displayed as Location <optional>
    "library-color.local"    //A proper hostname, make sure it is not duplicated <optional>
);

//Use URL to specify queue and include everything
let printer2 = new Printer(
    "ipp://10.20.0.95:631/ipp/print",
     "US Life Center",
     "Upper School 1st Floor");

//Or you can just give the ip address, the name will be set to like
// Untitled Bonjour Printer 10341
let anotherPrinter = new Printer("10.20.0.92");

//Add the printers to make proxy publish those printers
proxy.addPrinter(printer);
proxy.addPrinter(printer2);
proxy.addPrinter(anotherPrinter);

As of 1.2.0, you can let PrinterProxy automatically resolve the name and capabilities of the printer on a remote server supporting unicast dns service discovery. (e.g. a cups server)

You may need to adjust your printer's firewall & mdns responder settings to allow dns sd queries from your address.

//Resolve the printers broadcasting on 10.35.0.18
proxy.resolvePrinter("10.35.0.18");

//The optional callback function accepted in the second argument
proxy.resolvePrinter("10.35.0.18", (error, resolvedPrinters) => {
    //The 'error' parameter is null when successfully resolved the
    // printer, and an 'Error' object on error
    if(error){
        console.error("Error resolving printer", error);
    }
    
    //The 'resolvedPrinters' parameter is null when an error occurred.
    // An array of 'Printer' object on success
})

See src/test.js for more examples.