mod_zeroconf a zero configuration registration module for apache 2.0

38
mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Upload: lawrence-long

Post on 04-Jan-2016

250 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf

A Zero Configuration Registration Module for Apache 2.0

Page 2: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Sander Temme

[email protected]

Page 3: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Agenda

• Technology Overview

• Zeroconf Applications

• mod_zeroconf for Apache 2.0– Design– Demo– Code Walkthrough

• Q&A

Page 4: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

What is Zeroconf?

• IETF Working Group– Formed in Sept. 1999

• Usability of TCP/IP

• Enhancements to Existing Protocols

• Not SLP, …

Page 5: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

What is Zeroconf?

Page 6: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

What is Zeroconf?

• TCP/IP Autoconfiguration

• Network naming

• Service Browsing

Page 7: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Technology Overview

• Link-local addressing

• multicast DNS

• DNS Service-Discovery

Page 8: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Link-local Addressing

• No Central Address Server

• Pick a Random Address– In 169.254.0.0/16 range

• Address Defense

• Can Work With Centrally Assigned Addresses

Page 9: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Link-local Addressing

Printer

Network

169.254.1.219

169.254.4.51

169.254.10.29

169.254.4.51

Page 10: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mDNS

• DNS-like Protocol

• Every Host Runs Responder

• Hosts Pick Own Names

• Communication over IP Multicast

• Link-local

• Resolves to Link-local or Regular Address

Page 11: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Printer169.254.1.219

169.254.4.51

169.254.10.29

169.254.4.51

mDNSPC_BILL

PC_LARRY

lj21569478

Network

Mac_Steve

Page 12: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

DNS-SD

• Service Publishing and Browsing

• Uses Existing DNS Record types

• User Sees Only Service Names

• Works With mDNS or Regular DNS

Page 13: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

DNS-SD

Bill’s Files

Larry’s Tunes

Laserjet, Closet Under the Stairs

Printer169.254.1.219

169.254.4.51

169.254.10.29

169.254.4.51

PC_BILL

PC_LARRY

lj21569478

Network

Mac_Steve

Steve’s Movies

Page 14: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Applications

• Printer Configuration

• Music/Photo/Document Sharing

• Distributed Compilation

• Network gaming

• … (the sky is the limit)

Page 15: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Peer to Peer Chat

Page 16: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Sharing Tunes

Page 17: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Sharing Sites

Page 18: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Platform support

• MacOSX 10.2 and up

• Linux: several initiatives– Mandrake put it in the distribution– No one else so far

• Windows…– Link-local addressing works– Third-party mDNSResponder

Page 19: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Windows and Rendezvous

Page 20: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Zeroconf on Linux

• May need Link-local address– http://zeroconf.sourceforge.net/?selected=zcip – http://www.zeroconf.org/AVH-IPv4LL.c

• Need mDNSResponder– tmdns or– Apple’s mDNSResponder or

• http://developer.apple.com/darwin/projects/rendezvous/

– zmdns, openmdns (search SourceForge) or– Howl or– Embeddable: mdnsd http://www.dotlocal.org/mdnsd/ – Running Java? Try http://jmdns.sourceforge.net/

Page 21: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Zeroconf and Apache

• Goals– Publish Apache http services

– Work with external mDNSResponder

– Support Apache 2.0

– ASF Licensed

• Existing initiatives– mod_rendezvous: Apache 1.3, Mac only

– mod_rendezvous_apple: ditto

– mdnsmod: No code on SF, in ‘planning stage’

Page 22: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

External mDNSResponder

• Apple mDNSResponder– No client libraries

• zmdns– Wrapper around Apple code– Mixed BSD, APSL– Alpha stage

• openmdns, tmdns– GPL

Page 23: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Howl

• Based on Apple code

• Modified BSD license

• At version 0.9.3, API should be stable

• Linux, Windows, MacOSX, …

• Plugin for Windows Internet Explorer

http://www.porchdogsoft.com/products/

Page 24: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Configuration

# En/disable Zeroconf server-wide. Default: offZeroconf {on|off}

# Register main server or virtualhost container. ZeroconfRegister “service name” [/partialpath]

# This is part of the coreServerName hostname:port

Page 25: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Demo

Page 26: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf Design

Apache 2.0Core

HowlmDNSResponder

mod_zeroconf

Virtual Host Config Info

mDNS Registration

mDNS Callbacks

Page 27: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

What Gets Registered?

• Service Name

• SRV information: port, hostname, partial URI

• Hostname/IP (if different)

• Callback function

Page 28: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf Design

ApacheCore

HowlmDNSResponder

mod_zeroconf

Virtual Host Config Info

mDNS Registration

mDNS CallbacksCallbackProcess

Page 29: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Registration Callbacks

• Network can be very dynamic

• Service name, Hostname conflicts

• Apache needs to respond

• Can’t block parent process: – fork a child

Page 30: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf.c: post_configstatic int zc_post_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp, server_rec *s){ void *data; const char *userdata_key = "zeroconf_init_module";

apr_pool_userdata_get(&data, userdata_key, s->process->pool); if (!data) { apr_pool_userdata_set((const void *) 1, userdata_key, apr_pool_cleanup_null, s->process->pool); } else { . . . } return OK;}

Page 31: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf.c: config check/* Check if Zeroconf has been enabled globally. If not, bail here */cfg = our_sconfig(s);if (cfg->enabled == 0) { return OK;}/* Still here? Let's go. */TESTORBAIL(sw_rendezvous_init(&howl_session));

/* Get System Hostname (not shown) */

for (ws = s; ws; ws = ws->next) { cfg = our_sconfig(ws); if (cfg->serviceName) { . . . }}

Page 32: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf.c: TEXT Record

if (cfg->partialURI) { TESTORBAIL(sw_text_record_init(&text_record)); TESTORBAIL(sw_text_record_add_key_and_string_value(text_record, "path", cfg->partialURI)); pathinfo = sw_text_record_bytes(text_record); pilength = sw_text_record_len(text_record);} else { pathinfo = NULL; pilength = 0;}

serverport = ws->port == 0 ? 80 : ws->port;

if (apr_strnatcasecmp(thehostname, ws->server_hostname) != 0) { zc_register_host(ws);}

Page 33: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf.c: Publish!howl_result = sw_rendezvous_publish(howl_session, cfg->serviceName, "_http._tcp", NULL, ws->server_hostname, serverport, pathinfo, pilength, NULL, howl_publish_reply, (sw_opaque) ws, &howl_id);

pubidPtr = apr_palloc(s->process->pool, sizeof(sw_rendezvous_publish_id));*pubidPtr = howl_id;apr_pool_userdata_set(howl_id, cfg->serviceName, apr_pool_cleanup_null, ws->process->pool);

Page 34: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf.c: Fork callback#if APR_HAS_FORKcallbackchild = apr_palloc(s->process->pool, sizeof(apr_proc_t));

switch(forkstatus = apr_proc_fork(callbackchild, s->process->pool)) {case APR_INCHILD: sw_rendezvous_run(howl_session); break; /* Not reached */case APR_INPARENT: apr_pool_note_subprocess(s->process->pool, callbackchild, APR_KILL_AFTER_TIMEOUT); break;default: ap_log_error(APLOG_MARK, APLOG_ERR, forkstatus, s, "Failed to fork callback child"); return HTTP_INTERNAL_SERVER_ERROR;}#endif /* APR_HAS_FORK */

Page 35: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf: To-Dos

• Learn about https protocol• Learn about DAV, …• Port to MacOSX? Apache 1.3?• Alternative mDNS implementations• IPv6 compatibility• More solid hostname registration• Better callback code• etc…

Page 36: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

mod_zeroconf: Where?

• Project home page:– http://www.temme.net/sander/mod_zeroconf/

• Contact:– [email protected]

• About Apache server:– http://httpd.apache.org/

• Apache modules:– [email protected]

Page 37: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Conclusion

• Zeroconf is great

• Will make networks more usable

• Platform support needed across vendors

• Applications will follow

• mod_zeroconf is cool– Patches are welcome

Page 38: Mod_zeroconf A Zero Configuration Registration Module for Apache 2.0

Q&A