Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add IFSC service #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

gopuvenkat
Copy link

@gopuvenkat gopuvenkat commented Dec 31, 2024

Add IFSC service - Closes #81

IFSC data is read from disk and loaded into memory to respond to requests. The download link mentioned in config.sample.toml fetches the latest dump of IFSC data.

  1. make build output
❯ make build
CGO_ENABLED=0 go build -o dnstoys.bin -ldflags="-s -w -X 'main.buildString=v1.1.0-11-g22d3 (build "\#"22d3e73 2024-12-31 14:31:22)'" ./cmd/dnstoys/*.go
  1. Running DNS server
❯ ./dnstoys.bin
2024/12/31 14:32:19 main.go:72: reading config: config.toml
2024/12/31 14:32:19 main.go:162: reading geo locations from data/cities15000.txt
2024/12/31 14:32:21 main.go:170: 29275 geo location names loaded
2024/12/31 14:32:21 loading wordnet data from data/wordnet
2024/12/31 14:32:21 loaded wordnet dictionary data
2024/12/31 14:32:21 loading IFSC data from data/ifsc
2024/12/31 14:32:22 loaded IFSC data
2024/12/31 14:32:22 main.go:381: listening on  :5354
  1. Running queries from another terminal
❯ dig ABNA0000001.ifsc @127.0.0.1 -p 5354

; <<>> DiG 9.10.6 <<>> ABNA0000001.ifsc @127.0.0.1 -p 5354
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39574
;; flags: qr rd; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;ABNA0000001.ifsc.		IN	A

;; ANSWER SECTION:
ABNA0000001.ifsc.	1	IN	TXT	"BANK: Royal Bank of Scotland N.V."
ABNA0000001.ifsc.	1	IN	TXT	"BRANCH: RTGS-HO"
ABNA0000001.ifsc.	1	IN	TXT	"CITY: GREATER BOMBAY"
ABNA0000001.ifsc.	1	IN	TXT	"STATE: MAHARASHTRA"

;; Query time: 2 msec
;; SERVER: 127.0.0.1#5354(127.0.0.1)
;; WHEN: Tue Dec 31 14:40:30 IST 2024
;; MSG SIZE  rcvd: 236
❯ dig ANZB0000001.ifsc +short @127.0.0.1 -p 5354
"BANK: Australia and New Zealand Banking Group"
"BRANCH: RTGS-HO"
"CITY: MUMBAI"
"STATE: MAHARASHTRA"
❯ dig incorrectIFSC.ifsc @127.0.0.1 -p 5354

; <<>> DiG 9.10.6 <<>> incorrectIFSC.ifsc @127.0.0.1 -p 5354
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 62955
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;incorrectIFSC.ifsc.		IN	A

;; ADDITIONAL SECTION:
.			1	IN	TXT	"error: invalid IFSC code length: 13"

;; Query time: 1 msec
;; SERVER: 127.0.0.1#5354(127.0.0.1)
;; WHEN: Tue Dec 31 14:36:25 IST 2024
;; MSG SIZE  rcvd: 83

@gopuvenkat gopuvenkat changed the title Add IFSC service Feature: add IFSC service Jan 1, 2025
# You will need to manually download the IFSC data
# Download from https://github.com/razorpay/ifsc/releases/download/latest/by-bank.tar.gz
# Untar the folder and save its contents within data/ifsc directory
ifsc_path = "data/ifsc"
Copy link

@SaiSkandaTNI SaiSkandaTNI Jan 11, 2025

Choose a reason for hiding this comment

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

The below might be a useful addition to quick start this, a single commad to download and untar. Same canbe used in a cronjob to keep it upto date. Also might be useful to retain the by-bank/ folder incase another method / file from razorpay also needs to be included. The below unatars into ifsc/by-bank/

cd [your_dns_toys_data_directory] && mkdir -p ifsc && cd ifsc && mkdir -p by-bank && rm -r by-bank && curl -L -s $(curl -s https://api.github.com/repos/razorpay/ifsc/releases/latest | grep "browser_download_url" | grep "by-bank.tar.gz" | sed -E 's/.*"([^"]+)".*/\1/') -o by-bank.tar.gz && tar -xzf by-bank.tar.gz && rm by-bank.tar.gz

Copy link

@SaiSkandaTNI SaiSkandaTNI Jan 11, 2025

Choose a reason for hiding this comment

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

might also want to add data/ifsc to gitignore

Branch string `json:"BRANCH"`
City string `json:"CITY"`
State string `json:"STATE"`
}

Choose a reason for hiding this comment

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

Is it possible to send everything that is available instead of restricting to these 5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enhancement - ifsc service
2 participants