Skip to content

Commit

Permalink
refactor last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
denzs committed Dec 14, 2017
1 parent f2c4d5f commit 36bb6a1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 34 deletions.
16 changes: 8 additions & 8 deletions gofax.conf
Expand Up @@ -32,11 +32,11 @@ xferfaxlog = log/xferfaxlog
[gofaxd]
socket = 127.0.0.1:8022

; Accept re-invites to t.38 from other side while receiving (FreeSWITCH: fax_enable_t38)
acceptt38 = true
; Enable T.38 support for receiving (FreeSWITCH: fax_enable_t38)
enablet38 = true

; send re-invite to t.38 while receiving (FreeSWITCH: fax_enable_t38_request)
offert38 = true
; Send a T.38-ReINVITE when a fax was detected by tone detection while receiving (FreeSWITCH: fax_enable_t38_request)
requestt38 = true

; Wait before answering a incoming call (ms)
answerafter = 2000
Expand All @@ -48,11 +48,11 @@ waittime = 1000
;dynamicconfig = etc/DynamicConfig

[gofaxsend]
; Accept re-invites to t.38 from other side while sending (FreeSWITCH: fax_enable_t38)
acceptt38 = true
; Enable T.38 support for receiving (FreeSWITCH: fax_enable_t38)
enablet38 = true

; send re-invite to t.38 while sending (FreeSWITCH: fax_enable_t38_request)
offert38 = true
; Send a T.38-ReINVITE when a fax was detected by tone detection while sending (FreeSWITCH: fax_enable_t38_request)
requestt38 = true

; Default outgoing caller id number
faxnumber = 4711
Expand Down
22 changes: 7 additions & 15 deletions gofaxd/server.go
Expand Up @@ -163,18 +163,18 @@ func (e *EventSocketServer) handler(c *eventsocket.Connection) {
logger.Logger.Println(channelUUID, "Logging events for commid", sessionlog.CommID(), "to", sessionlog.Logfile())
sessionlog.Log("Inbound channel UUID: ", channelUUID)

// Check if T.38 should be disabled
offerT38 := gofaxlib.Config.Gofaxsend.OfferT38
acceptT38 := gofaxlib.Config.Gofaxsend.AcceptT38
// Check if T.38 should be enabled
requestT38 := gofaxlib.Config.Gofaxd.RequestT38
enableT38 := gofaxlib.Config.Gofaxd.EnableT38

fallback, err := gofaxlib.GetSoftmodemFallback(nil, cidnum)
if err != nil {
sessionlog.Log(err)
}
if fallback {
sessionlog.Logf("Softmodem fallback active for caller %s, disabling T.38", cidnum)
acceptT38 = false
offerT38 = false
enableT38 = false
requestT38 = false
}
sessionlog.Logf("Accepting call to %v from %v <%v> via gateway %v with commid %v", recipient, cidname, cidnum, gateway, sessionlog.CommID())

Expand Down Expand Up @@ -211,16 +211,8 @@ func (e *EventSocketServer) handler(c *eventsocket.Connection) {

sessionlog.Log("Rxfax to", filenameAbs)

if acceptT38 {
c.Execute("set", "fax_enable_t38=true", true)
} else {
c.Execute("set", "fax_enable_t38=false", true)
}
if offerT38 {
c.Execute("set", "fax_enable_t38_request=true", true)
} else {
c.Execute("set", "fax_enable_t38_request=false", true)
}
c.Execute("set", fmt.Sprintf("fax_enable_t38=%s", strconv.FormatBool(enableT38)), true)
c.Execute("set", fmt.Sprintf("fax_enable_t38_request=%s", strconv.FormatBool(requestT38)), true)
c.Execute("set", fmt.Sprintf("fax_ident=%s", csi), true)
c.Execute("rxfax", filenameAbs, true)
c.Execute("hangup", "", true)
Expand Down
8 changes: 4 additions & 4 deletions gofaxlib/config.go
Expand Up @@ -46,8 +46,8 @@ type config struct {
Xferfaxlog string
}
Gofaxd struct {
AcceptT38 bool
OfferT38 bool
EnableT38 bool
RequestT38 bool
Socket string
Answerafter uint64
Waittime uint64
Expand All @@ -56,8 +56,8 @@ type config struct {
AllocateInboundDevices bool
}
Gofaxsend struct {
AcceptT38 bool
OfferT38 bool
EnableT38 bool
RequestT38 bool
FaxNumber string
CallPrefix string
DynamicConfig string
Expand Down
14 changes: 7 additions & 7 deletions gofaxsend/transmission.go
Expand Up @@ -104,18 +104,18 @@ func (t *transmission) start() {
return
}

// Check if T.38 should be disabled
offerT38 := gofaxlib.Config.Gofaxsend.OfferT38
acceptT38 := gofaxlib.Config.Gofaxsend.AcceptT38
// Check if T.38 should be enabled
requestT38 := gofaxlib.Config.Gofaxsend.RequestT38
enableT38 := gofaxlib.Config.Gofaxsend.EnableT38

fallback, err := gofaxlib.GetSoftmodemFallback(t.conn, t.faxjob.Number)
if err != nil {
t.sessionlog.Log(err)
}
if fallback {
t.sessionlog.Logf("Softmodem fallback active for destination %s, disabling T.38", t.faxjob.Number)
acceptT38 = false
offerT38 = false
enableT38 = false
requestT38 = false
}

// Assemble dialstring
Expand All @@ -128,8 +128,8 @@ func (t *transmission) start() {
"fax_header": t.faxjob.Header,
"fax_use_ecm": strconv.FormatBool(t.faxjob.UseECM),
"fax_disable_v17": strconv.FormatBool(t.faxjob.DisableV17),
"fax_enable_t38": strconv.FormatBool(acceptT38),
"fax_enable_t38_request": strconv.FormatBool(offerT38),
"fax_enable_t38": strconv.FormatBool(enableT38),
"fax_enable_t38_request": strconv.FormatBool(requestT38),
"fax_verbose": strconv.FormatBool(gofaxlib.Config.Freeswitch.Verbose),
}

Expand Down

0 comments on commit 36bb6a1

Please sign in to comment.