;
; This example shows how to use SQL as a backend database to
; authenticate the endpoints.
;
; Currently two SQL drivers are supported: MySQL and PostgreSQL

[Gatekeeper::Main]
Fortytwo=42
Name=OpenH323GK
TimeToLive=300

[RoutedMode]
GKRouted=1
H245Routed=0

[Gatekeeper::Auth]
SQLPasswordAuth=optional;RRQ
SQLAliasAuth=required;RRQ
SQLAuth=required;Setup,SetupUnreg
default=allow

[SQLPasswordAuth]
Driver=MySQL
;Driver=PostgreSQL
Host=localhost
Database=billing
Username=gnugk
Password=secret
CacheTimeout=300
Query=SELECT h235password FROM users WHERE alias = '%1' AND IS active
MinPoolSize=5

[SQLAliasAuth]
Driver=MySQL
;Driver=PostgreSQL
Host=localhost
Database=billing
Username=gnugk
Password=secret
CacheTimeout=300
Query=SELECT aliasauthcondition FROM users WHERE alias = '%1' AND IS active
MinPoolSize=1

[SQLAuth]
Driver=PostgreSQL
;Driver=MySQL
Host=localhost
Database=billing
Username=gnugk
Password=secret
MinPoolSize=3
CallQuery=SELECT active, getcredittime('%u', '%{Called-Station-Id}') AS credittime FROM users UNION SELECT FALSE, 0 AS credittime


[SQLAcct]
Driver=MySQL
;Driver=PostgreSQL
Host=localhost
Database=billing
Username=gnugk
Password=secret
MinPoolSize=5
StartQuery=INSERT INTO call (gkname, sessid, callno, username, calling, called, duration, disconnectcause) VALUES ('%g', '%s', %n, '%u', '%{Calling-Station-Id}', '%{Called-Station-Id}', %d, %c)
StartQueryAlt=UPDATE call SET username = '%u', calling = '%{Calling-Station-Id}', called = '%{Called-Station-Id}', duration = %d, disconnectcause = %c WHERE gkname = '%g' AND sessid = '%s'
UpdateQuery=UPDATE call SET duration = %d WHERE gkname = '%g' AND sessid = '%s'
StopQuery=UPDATE call SET username = '%u', calling = '%{Calling-Station-Id}', called = '%{Called-Station-Id}', duration = %d, disconnectcause = %c WHERE gkname = '%g' AND sessid = '%s'
StopQueryAlt=INSERT INTO call (gkname, sessid, callno, username, calling, called, duration, disconnectcause) VALUES ('%g', '%s', %n, '%u', '%{Calling-Station-Id}', '%{Called-Station-Id}', %d, %c)
TimestampFormat=MySQL

[CallTable]
GenerateNBCDR=TRUE
GenerateUCCDR=TRUE
DefaultCallTimeout=7200

[GkStatus::Auth]
rule=allow

