Skip to content

Commit

Permalink
Added accounting by sender address
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Lazzaris committed Jan 9, 2019
1 parent f581856 commit 203cbea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions polka.cf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dbname=policy
badmailfrom_table=badmailfrom
badmailto_table=badmailto
policy_table=relay_policy
sender_accounting=0
9 changes: 9 additions & 0 deletions polka.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func policy_verify(xdata connData, db *sql.DB) string {
var xtype,xitem, mx, quota, ts string;
var fmax, fquota float64;
var last_ts, now int64;
sender_accounting,err_a :=strconv.ParseInt(cfg["sender_accounting"],10,8)
if err_a!=nil {
sender_accounting=0
}

if !sender_permitted(xdata,db) {
xlog.Info("Rejecting bad sender "+xdata.sender)
return "REJECT bad sender"
Expand All @@ -109,6 +114,10 @@ func policy_verify(xdata connData, db *sql.DB) string {
if (*xdebug) { fmt.Println("Using username: ", xdata.sasl_user) }
xtype="U"
xitem=xdata.sasl_user
case xdata.sender!="" && sender_accounting==1:
if (*xdebug) { fmt.Println("Using Sender: ", xdata.sender) }
xtype="S"
xitem=xdata.sender
case xdata.ip_address!="":
if (*xdebug) { fmt.Println("Using IP: ", xdata.ip_address) }
xtype="I"
Expand Down

0 comments on commit 203cbea

Please sign in to comment.