forked from gonicus/gofaxip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement fallback to softmodem for failed T.38 transmissions
- Loading branch information
Markus Lindenberg
committed
May 28, 2014
1 parent
4b28668
commit 00d9045
Showing
9 changed files
with
226 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configuration name="db.conf" description="LIMIT DB Configuration"> | ||
<settings> | ||
<!--<param name="odbc-dsn" value="dsn:user:pass"/>--> | ||
</settings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package gofaxlib | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fiorix/go-eventsocket/eventsocket" | ||
) | ||
|
||
func FreeSwitchDBInsert(c *eventsocket.Connection, realm string, key string, value string) error { | ||
_, err := c.Send(fmt.Sprintf("api db insert/%s/%s/%s", realm, key, value)) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func FreeSwitchDBDelete(c *eventsocket.Connection, realm string, key string) error { | ||
_, err := c.Send(fmt.Sprintf("api db delete/%s/%s", realm, key)) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func FreeSwitchDBSelect(c *eventsocket.Connection, realm string, key string) (string, error) { | ||
result, err := c.Send(fmt.Sprintf("api db select/%s/%s", realm, key)) | ||
if err != nil { | ||
return "", err | ||
} | ||
return result.Body, nil | ||
} | ||
|
||
func FreeSwitchDBExists(c *eventsocket.Connection, realm string, key string) (bool, error) { | ||
result, err := c.Send(fmt.Sprintf("api db exists/%s/%s", realm, key)) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return result.Body == "true", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package gofaxlib | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fiorix/go-eventsocket/eventsocket" | ||
"time" | ||
) | ||
|
||
const ( | ||
MOD_DB_FALLBACK_REALM = "fallback" | ||
) | ||
|
||
func GetSoftmodemFallback(c *eventsocket.Connection, cidnum string) (bool, error) { | ||
if !Config.Freeswitch.SoftmodemFallback || cidnum == "" { | ||
return false, nil | ||
} | ||
|
||
var err error | ||
if c == nil { | ||
c, err = eventsocket.Dial(Config.Freeswitch.Socket, Config.Freeswitch.Password) | ||
if err != nil { | ||
return false, err | ||
} | ||
defer c.Close() | ||
} | ||
|
||
exists, err := FreeSwitchDBExists(c, MOD_DB_FALLBACK_REALM, cidnum) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return exists, nil | ||
} | ||
|
||
func SetSoftmodemFallback(c *eventsocket.Connection, cidnum string, enabled bool) error { | ||
if !Config.Freeswitch.SoftmodemFallback || cidnum == "" { | ||
return nil | ||
} | ||
|
||
var err error | ||
if c == nil { | ||
c, err = eventsocket.Dial(Config.Freeswitch.Socket, Config.Freeswitch.Password) | ||
if err != nil { | ||
return err | ||
} | ||
defer c.Close() | ||
} | ||
|
||
return FreeSwitchDBInsert(c, MOD_DB_FALLBACK_REALM, cidnum, fmt.Sprintf("%d", time.Now().Unix())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters