Skip to content

Commit

Permalink
Minor improvements to conn-trac
Browse files Browse the repository at this point in the history
Signed-off-by: Richard T Bonhomme <[email protected]>
  • Loading branch information
TinCanTech committed Aug 11, 2021
1 parent 0e9685e commit 31a6793
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions easytls-client-connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,16 @@ conn_trac_connect ()
update_status "TLS-Crypt-V2 key added to conn-trac"
fi
unset file_data
}
} # => conn_trac_connect ()

# Update connection tacking - disconnect
conn_trac_disconnect ()
{
[ $ENABLE_CONN_TRAC ] || return 0
"${EASYTLS_SED}" -i "/^${tlskey_serial}\$/d" "${EASYTLS_CONN_TRAC}"
update_status "TLS-Crypt-V2 key removed from conn-trac"
}
[ -s "${EASYTLS_CONN_TRAC}" ] || "${EASYTLS_RM}" -f "${EASYTLS_CONN_TRAC}"
} # => conn_trac_disconnect ()

# Initialise
init ()
Expand Down Expand Up @@ -375,10 +376,12 @@ if [ -f "${TCV2KEY_SERIAL_FILE}" ]
then
tlskey_serial="$("${EASYTLS_CAT}" "${TCV2KEY_SERIAL_FILE}")" || \
die "Failed to set tlskey_serial"
update_status "Found tlskey-serial"
"${EASYTLS_RM}" "${TCV2KEY_SERIAL_FILE}"
else
# Not using TLS-Crypt-V2 key
tlskey_serial="00000000000000000000000000000000"
update_status "NO TLSKEY SERIAL"
fi

# easytls client metadata file
Expand Down
3 changes: 2 additions & 1 deletion easytls-client-disconnect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ conn_trac_disconnect ()
[ $ENABLE_CONN_TRAC ] || return 0
"${EASYTLS_SED}" -i "/^${tlskey_serial}\$/d" "${EASYTLS_CONN_TRAC}"
update_status "TLS-Crypt-V2 key removed from conn-trac"
}
[ -s "${EASYTLS_CONN_TRAC}" ] || "${EASYTLS_RM}" -f "${EASYTLS_CONN_TRAC}"
} # => conn_trac_disconnect ()

# Initialise
init ()
Expand Down
7 changes: 4 additions & 3 deletions easytls-cryptv2-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ conn_trac_connect ()
[ $ENABLE_CONN_TRAC ] || return 0
[ -f "${EASYTLS_CONN_TRAC}" ] && \
file_data="$("${EASYTLS_CAT}" "${EASYTLS_CONN_TRAC}")"
if "${EASYTLS_GREP}" "^${tlskey_serial}$" "${EASYTLS_CONN_TRAC}"
if "${EASYTLS_GREP}" -q "^${tlskey_serial}$" "${EASYTLS_CONN_TRAC}"
then
# Already connected don't add another
update_status "TLS-key serial is already registered in conn-trac"
Expand All @@ -454,7 +454,7 @@ conn_trac_connect ()
update_status "TLS-Crypt-V2 key added to conn-trac"
fi
unset file_data
}
} # => conn_trac_connect ()

# Initialise
init ()
Expand Down Expand Up @@ -1018,9 +1018,10 @@ else
die "Failed to create client_metadata_file" 89
update_status "Created client_metadata_file"

# Ugly generic_metadata_file hack
# Unfortunate generic_metadata_file hack
if [ -f "${generic_metadata_file}" ]
then
#die "Why This File - generic_metadata_file"
"${EASYTLS_RM}" -f "${generic_metadata_file}"
update_status "Deleted generic_metadata_file"
"${EASYTLS_CP}" "${OPENVPN_METADATA_FILE}" "${generic_metadata_file}" || \
Expand Down
3 changes: 2 additions & 1 deletion easytls-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ conn_trac_disconnect ()
[ $ENABLE_CONN_TRAC ] || return 0
"${EASYTLS_SED}" -i "/^${tlskey_serial}\$/d" "${EASYTLS_CONN_TRAC}"
update_status "TLS-Crypt-V2 key removed from conn-trac"
}
[ -s "${EASYTLS_CONN_TRAC}" ] || "${EASYTLS_RM}" -f "${EASYTLS_CONN_TRAC}"
} # => conn_trac_disconnect ()

# Create stage-1 file
create_stage1_file ()
Expand Down

1 comment on commit 31a6793

@TinCanTech
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.